This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to use the command ---java ? 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 "How to use the command ---java ?" Watch "How to use the command ---java ?" New topic

How to use the command ---java ?

Tom John

Joined: Apr 15, 2002
Posts: 29
I have a java file , . It import some class in the test.jar . Now I put the command :
Javac –cp c:\..\test.jar c:\..\
Now I have compiled it successfully !
But when I use the java to use this class , like below :
Java –cp c:\..\test.jar Test
Then system output :
Exception in thread "main" java.lang.NoClassDefFoundError: com/TestForPie
This is show that the command java can not find the Test.class . It’s sure that I have use command java and its arguments wrongly . how can use java to run my class ? And what’s wrong with me ?
Note : in my , I don’t use package to pack this java file in any packages .
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
Does your file have a main method with the following signature:
public static void main(String args[])
Because if it doesn't then this is the place to start. Although it is kind weird that the error is specifying the class TestForPie.
Is TestForPie the main class in the jar file?
If so then you might want to specify where the file is located in the -cp agrument also for example:
java -cp C:\Test\location;c:\..\test.jar Test
Hope this helps.

SCJP 1.4<br /><a href="" target="_blank" rel="nofollow"></a>
It is sorta covered in the JavaRanch Style Guide.
subject: How to use the command ---java ?
Similar Threads
Junilu, Ian, Peter and others pls help
create jar problem: jarFile.jar: no such file or directory
Trouble running program from within a jarfile
Complie time using custom classloader for decryption.
Question on jar files and classpath.