aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "classpath" Watch "classpath" New topic
Author

classpath

Christopher Collier
Greenhorn

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\QTJava.zip

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: 281


Hi,

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.

hope this would be useful.

if you like to read more about classpath you can check my blog post http://javarevisited.blogspot.com/2011/01/how-classpath-work-in-java.html


http://javarevisited.blogspot.com - java classpath - Java67 - java hashmap - java logging tips java interview questions Java Enum Tutorial
Christopher Collier
Greenhorn

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: http://aspose.com/file-tools
 
subject: classpath