File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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 Method)


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.


Rajeev Trikha (SCJP 6)
subject: jar classpath
It's not a secret anymore!