• 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

Execute Java Classes from command line

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,
I created a project with 2 packages , and no external libraries required , that works well on eclipse.
But when I try to run it from command line java give me strange errors : (note that java is correctly set to the path).

My project is located at C:\thesis\thesis\classes
then I have 2 packages "app" and "agentLibrary".
I have simply to exectute the Main class in "app" (which cointains reference to some "agentLibrary" classes).(The main class has a void main method with no parameters).
I tried this : C:> java -classpath C:\thesis\thesis\classes\ app.Main
but I get errors...Exception in thread "main" java.lang.NoClassDefFoundError app/Main
How do I solve this problem?
Thanks!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the file C:\thesis\thesis\classes\app\Main.class exist?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java -classpath C:\thesis\thesis\classes\ app.Main

Remove the backslash at the end of the classpath (after "classes").
reply
    Bookmark Topic Watch Topic
  • New Topic