views:

58

answers:

4

Hi all,

I'm having a little trouble running some Java code, which requires three .jar files to be used. I'm at a lost as to what to do with them--I've tried setting the CLASSPATH (and following the instructions for how to do so in the readme files), but to no avail.

I was wondering if someone could walk me through it? I'd imagine three .jar files would be an easy install for someone who knows what they're doing.

If it helps, I'm using Ubuntu pretty much right out of the box (but I do have JDK and Eclipse installed!)

Runtime library: http://cogcomp.cs.illinois.edu/download/software/20

Additional .jar needed: http://cogcomp.cs.illinois.edu/download/software/23

Program I ultimately need to run: http://cogcomp.cs.illinois.edu/download/software/26

If you're willing to help, I can't thank you enough--you deserve a million kudos!

G

A: 

If you are using java -jar to run your jar files, then the CLASSPATH variable is ignored. If you are using java -jar, you have two options:

  1. Combine the three jars into one jar.
  2. Run the main class directory and don't use -jar.
Starkey
A: 

You need to set the CLASSPATH .place all the 3 jars in a folder , name it as lib See below to set classpath

set CLASSPATH=%CLASSPATH%:lib;

Suresh S
A: 

Use of the CLASSPATH environment variable is generally discouraged nowadays. This is how it's done (on Linux):

java -cp library1.jar:library2.jar:mainapp.jar <fully qualified name of main class>
Michael Borgwardt
So, since I have 3 .jar files, would I do:
Georgina
java -cp library1.jar:library2.jar:library3.jar:mainapp.jar ?
Georgina
Ohh, I see what you mean. java -cp library1.jar:library2.jar:mainapp.jar Main.class
Georgina
When I do this, I get: Exception in thread "main" java.lang.NoClassDefFoundError: Main/classCaused by: java.lang.ClassNotFoundException: Main.class at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266)Could not find the main class: Main.class. Program will exit.
Georgina
@Georgina: the name of the class does not include the .class filename suffix, but it does possibly include a package prefix. "Main.class" would be interpreted as a class named "class" inside a package named "Main".
Michael Borgwardt
+1  A: 

Those are all JAR files. When you execute a JAR file by doubleclicking or using java -jar, the CLASSPATH environment variable and the -cp and -classpath arguments are ignored. The classpath should be defninied in META-INF/MANIFEST.MF file of the JAR. In this particular case, only the second and third JAR have a Class-Path entry in the manifest file:

Class-Path: LBJ2Library.jar

Which is the first JAR. The classpath is telling that it is expecting the LBJ2Library.jar to be in the same folder as the JAR you'd like to execute (either the second or third one).

So, just drop them all in the same folder and execute by java -jar LBJPOS.jar.

BalusC
I got it working by combining all the .jar files into a single .jar. It works!
Georgina