Meaningless Drivel is fun!
The moose likes EJB and other Java EE Technologies and the fly likes classpath questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "classpath questions" Watch "classpath questions" New topic

classpath questions

Karina Guenther
Ranch Hand

Joined: Sep 16, 2005
Posts: 62
One thing that I am not clear about in the Headfirst EJB book - what should I set my default classpath to? Do I need to set it to grab all of the jar files in my Sun/Appserver/lib dir? Also, I set it like a standard environment variable right?

I ask this basic question because the book has me do javac -classpath {$CLASSPATH}:MyPackage.jar when I'm compiling the client source code. So, if someone could clarify this for me I'd appreciate it. note: I was able to get my thing to compile by doing the following:

javac -classpath c:\sun\appserver\lib\ejb-3_0-api.jar;AdviceAppClient.jar

However, even with this I'm now unable to get it to run using the HF (and various modifications based on what worked for the compile) command of
java -cp {$CLASSPATH}:AdviceAppClient.jar AdviceClient

with all of them I get:
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient

My dir looks like this:
Directory of C:\My_Programs\EJBClass\Advice

01/25/2007 12:17 PM <DIR> .
01/25/2007 12:17 PM <DIR> ..
01/18/2007 11:00 PM 4,018 AdviceApp.ear
01/18/2007 04:44 PM 4,018 AdviceAppClient.jar
01/25/2007 12:34 PM 1,008 AdviceClient.class
01/18/2007 10:45 PM 1,152
01/04/2007 07:34 AM <DIR> classes
01/02/2007 02:36 PM <DIR> src

I also followed the instructions for the deployment and have the server running. So what did I miss?
Sumit Malik
Ranch Hand

Joined: Jan 05, 2007
Posts: 84
Hi Kari Gunter,

Here by {$CLASSPATH} HF is referring to classpath environment variable and along with that if you want to add additional jar then you can. e.g.,

java -cp {$CLASSPATH}:AdviceAppClient.jar

here along with classpath jar's you are adding AdviceAppClient.jar which needs for proper compilation of your java source and you are seperating it with colon( sign(: is seperator on linux platform)...

Well, do add AdviceAppClient.jar in the lib directory of you module and it will start running...

I hope this is what making you slight confusing....

Do let me know if i can assist you more

Cheers !!!
Sumit Malik

If at first you don't succeed, don't try skydiving
I agree. Here's the link:
subject: classpath questions
It's not a secret anymore!