Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading jar files for a .class file

 
Arno Pronk
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with a program that i wrote called chat. I need to run it in a command box with the command "java chat". However it needs a few extra jar files to run. Is there anyway i can use a parameter (like -classpath) to load the following jar files with the program i wrote?
/home/arno/jboss-4.2.3.GA/server/default/lib/Jboss-j2ee.jar
/home/arno/jboss-4.2.3.GA/server/default/lib/jpnserver.jar
/home/arno/jboss-4.2.3.GA/server/default/lib/jbossmq.jar
/home/arno/jboss-4.2.3.GA/lib/jboss-common.jar
/home/arno/jboss-4.2.3.GA/lib/concurrent.jar

Regards, Arno
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

If you look in the documentation for the java tool, you will find the -classpath (or -cp) option, which might provide what you need.
 
Arno Pronk
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for the reply

I still cant get it to work, so i would appreciate some more help.

It try to run it now with the command:

java -classpath /home/arno/jboss-4.2.3.GA/server/default/lib/:/home/arno/jboss-4.2.3.GA/lib/:/home/arno/workspace/5SimpleChatServer/bin/ Chat

Is this the right use of claspath?

The error that I keep getting is:
:~/workspace/5SimpleChatServer/bin$ java -classpath /home/arno/jboss-4.2.3.GA/server/default/lib/:/home/arno/jboss-4.2.3.GA/lib/:/home/arno/workspace/5SimpleChatServer/bin/ Chat
Exception in thread "main" java.lang.NoClassDefFoundError: Chat
at java.lang.Class.initializeClass(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: javax.jms.JMSException not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/arno/jboss-4.2.3.GA/server/default/lib/,file:/home/arno/jboss-4.2.3.GA/lib/,file:/home/arno/workspace/5SimpleChatServer/bin/], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.90)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.Class.forName(libgcj.so.90)
at java.lang.Class.initializeClass(libgcj.so.90)

 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you follow the 'Setting the Class path' link in the page that Campbell linked to you will find this
For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file.
 
Arno Pronk
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! I got it working now.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic