aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jar classpath" Watch "jar classpath" New topic
Author

jar classpath

Brian R Wolf
Greenhorn

Joined: Jan 25, 2010
Posts: 18

Hi,

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


Thanks

Brian
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)
 
Consider Paul's rocket mass heater.
 
subject: jar classpath