• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use the command ---java ?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a java file , Test.java . It import some class in the test.jar . Now I put the command :
Javac –cp c:\..\test.jar c:\..\Test.java
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 Test.java , I don’t use package to pack this java file in any packages .
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does your Test.java 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 Test.java file is located in the -cp agrument also for example:
java -cp C:\Test\location;c:\..\test.jar Test
Hope this helps.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic