File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "classpath" Watch "classpath" New topic


Christopher Collier

Joined: Feb 16, 2011
Posts: 22

Hey everyone,
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:

.;C:\Program Files\Java\jre6\lib\ext\

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!

Working steadily toward my SCJP.....
Javin Paul
Ranch Hand

Joined: Oct 15, 2010
Posts: 295


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 "" 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.

hope this would be useful.

if you like to read more about classpath you can check my blog post

SQL Query Interview Question java67 Javarevisited
Christopher Collier

Joined: Feb 16, 2011
Posts: 22

That helps, thanks.

I read your blog and got a lot of useful information out of it. Good stuff.
I agree. Here's the link:
subject: classpath
It's not a secret anymore!