wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes jar classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jar classpath" Watch "jar classpath" New topic

jar classpath

Brian R Wolf

Joined: Jan 25, 2010
Posts: 18


I know this class: org.apache.pig.Main exists in /cygdrive/c/pigtute/pigtmp/pig.jar , but when I run this, it doesn't seem to find it.

$ java -cp /cygdrive/c/pigtute/pigtmp/pig.jar org.apache.pig.Main

java.lang.NoClassDefFoundError: org/apache/pig/Main
Caused by: java.lang.ClassNotFoundException: org.apache.pig.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLCl


Rajeev Trikha
Ranch Hand

Joined: Jan 29, 2010
Posts: 85
Use the syntax java -jar jar-file

Before you execute this command make sure the runtime environment has an information of which class within the JAR file is the application's entry point.

To indicate which class is the application's entry point, you must add a Main-Class header to the JAR file's manifest. The header takes the form:

Main-Class: classname

The header's value, classname, is the name of the class that's the application's entry point.

See http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html

Rajeev Trikha (SCJP 6)
I agree. Here's the link: http://aspose.com/file-tools
subject: jar classpath
Similar Threads
cppunit testing
servlet compile problem
cppunit and netbeans
java on cygwin
Launch ant from cygwin