• 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

Not able to execute after sucessfull compilation

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Marshal
Posts: 79239
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic