• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to execute after sucessfull compilation

 
nitude gupta
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I m getting this exception when I m trying to execute my java program
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: Java/Te
st_java/Test)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Test. Program will exit.

The problem is not with classpath I suppose as i am able to run a simple "Hello world" program...
any help on this....
TIA...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.your Test class contain main method?
2. do you try to run the Test class with proper package name? example: java com.Test
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:1.your Test class contain main method?
2. do you try to run the Test class with proper package name? example: java com.Test


Yeah
These two checks should solve your problem...
If not... please put here your code and the commands of how you are running it...
 
nitude gupta
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DBConnection.java
This file is defined @ E:\Java\Test_java


Test.java
This file is defined @ E:\Java\Test_java



and I have defined connection.properties @ pkg "E:\Java\Test_java\properties"
I am compiling it using
E:\Java\Test_java>javac *.java

for executing this I am using

E:\Java\Test_java>java Java.Test_java.Test

and getting this err:

Exception in thread "main" java.lang.NoClassDefFoundError: Java/Test_java/Test
Caused by: java.lang.ClassNotFoundException: Java.Test_java.Test
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Java.Test_java.Test. Program will exit.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The problem is here . execute the class file from outside the package. i.e from E directory itself.


by the way: Please have a look at Java naming conventions
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:
The problem is here . execute the class file from outside the package. i.e from E directory itself.


by the way: Please have a look at Java naming conventions



correct solution... and yeah... a good look at the Java naming conventions is defibnitly required.

Also,
If there is some moderator listening right now... please delete one of my previous posts...
it got replicated because there was some network problem while I was posting it. I apologise for this...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49472
64
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anupam Jain wrote:. . . If there is some moderator listening right now... please delete one of my previous posts...
it got replicated because there was some network problem while I was posting it. I apologise for this...
Done
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Anupam Jain wrote:. . . If there is some moderator listening right now... please delete one of my previous posts...
it got replicated because there was some network problem while I was posting it. I apologise for this...
Done



thanks Ritchie..
That was really lightning quick...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49472
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic