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  Execute Java Classes from command line 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 " Execute Java Classes from command line" Watch " Execute Java Classes from command line" New topic
Author

Execute Java Classes from command line

Andrew Prinoli
Greenhorn

Joined: Jan 11, 2007
Posts: 22
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!!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Does the file C:\thesis\thesis\classes\app\Main.class exist?


Ping & DNS - my free Android networking tools app
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

java -classpath C:\thesis\thesis\classes\ app.Main

Remove the backslash at the end of the classpath (after "classes").


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
Consider Paul's rocket mass heater.
 
subject: Execute Java Classes from command line
 
Similar Threads
Running Java Programs from the command prompt
Command line argument question.
Jython use in a web-app
core java (j2se 5.0) tutorial & package
confusion about classpath and packages