• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NoClassDefFoundError  RSS feed

 
Eshwara Chaluvaiah
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello evryone
i am running a class from commandline in linux environment but i am getting java.lang.NoClassDefFoundError when i run the class. I am very confused about packages when running in command line. please can you tell me how to declare correct packages when developing a program without using any IDE. when i use IDE it wont be a problem but if i use some editor then i am very confused about that. Below is my program. please help me how to run the program?

package is start from the root. that is current directory is /media/Movies/eshwar/myjava
And Am using below command to run the program.Even though UseCaseTracker.class file in the currect direcotory i can't execute that.
java UseCaseTracker
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class is no longer called UseCaseTracker but media.Movies.eshwar.myjava.UseCaseTracker.
Look at the links in this old post. Some of them will be useful … and some not!
 
Eshwara Chaluvaiah
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi am still confuse about classes and packages while executing in command line. Below is my two simple classes which are in the same directory. namely Myclass.java and ClassUser.java.
Both the classes are in the directory /media/Movies/eshwar/myjava . and i have defined classes as follows(both are in separate file)
1)Myclass.java

2. ClassUser.java



i am compiling ClassUser.java in the directory myjava as follows
:/media/Movies/eshwar/myjava$ javac ClassUser.java

when i execute above command am getting symbol not found : myclass
according to me both are in same file, so it should compile but why its giving errror like this. even i used below command but got the same error

:/media/Movies/eshwar/myjava$ javac -cp . ClassUser.java

please help me to undestand packages and classes while executing in the command line
Advance thanks

 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eshwara Chaluvaiah wrote: . . .
i am compiling ClassUser.java in the directory myjava as follows
:/media/Movies/eshwar/myjava$ javac ClassUser.java

when i execute above command am getting symbol not found : myclass
according to me both are in same file, so it should compile but why its giving errror like this. even i used below command but got the same error

:/media/Movies/eshwar/myjava$ javac -cp . ClassUser.java

please help me to undestand packages and classes while executing in the command line
Advance thanks

Both methods are wrong. It is too late for me to go through the old posts now, I am afraid. Did you not find the -d option?
 
Eshwara Chaluvaiah
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone
after struggling to understand about the javac command finally it got worked using the following commands

/media/Movies/eshwar$ javac -d . myjava/ClassUser.java
/media/Movies/eshwar$ java myjava.ClassUser

 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!