I've been ducking this issue for a while and it's finally caught up with me (and in Chapter 1 of my new book, no doubt).
This question applies to a Windows system (I dual-boot Linux, but I'm still learning it, so I code in Windows).
Also, I'm compiling with an IDE, not from the command line.
Anyways, the Bates/Sierra SCJP 6 book has tasked me with creating a package, which I was able to ignore in school because my professor didn't delve into package access at all. Specially, the question says to:
"Create a directory called food off the directory in your class path setting."
My question is simply, where is this? My system's classpath variable is listed as:
But my IDE lists the default classpath as C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\lib\dt.jar;C:\Program Files\Java\jdk1.6.0_23\lib\tools.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\ext\sunpkcs11.jar.
I know I should (and eventually will) switch everything over to my Linux partition. Also, I clearly had some trouble when I was installing the JDK. Still, I'd appreciate advice and thoughts on this. Thanks!
Creating package is nothing but creating directory in Java.
if you are not using IDE then just create directory "mkdir -p com/test" and now create a class call "HelloWorld.java" and in the top of this
file put "package com.test" and keep this find inside directory "com/test".
essentially package com.test tells Java compiler / interpreter to where to look for this particular file in classpath. In case if you classpath contains
current directory "." then Java will look for class called HelloWorld.class inside directory ./com/test/
so if you are using IDE its even simpler if you are using Eclipse then it gives you option of create a new package and corresponding directory get created inside "src" folder of your project directory in Eclipse workspace.