• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Loading jar files for a .class file

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 73257
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)


 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! I got it working now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic