wood burning stoves*
The moose likes Beginning Java and the fly likes NoClassDefFoundError in a simple program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFoundError in a simple program" Watch "NoClassDefFoundError in a simple program" New topic
Author

NoClassDefFoundError in a simple program

harish gowda Java green
Greenhorn

Joined: Nov 30, 2009
Posts: 4
I am running this program:


package com.test;

public class Test1 {

/**
* @param args
*/
public static void main(String[] args) {

System.out.println("Hello");

}

}

I got the following..not able to figure out the reason? Any help would be welcome..Thanks


C:\tmp\Test1>java Test1
Exception in thread "main" java.lang.NoClassDefFoundError: Test1 (wrong name: co
m/test/Test1)
at java.lang.ClassLoader.defineClass1(Native Method)
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Test1. Program will exit.


Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
java com.test.Test1

and moving to a more appropriate location.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3606
    
  15
I don't know where you moved this one from but there is another one here


Joanne
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Joanne Neal wrote:I don't know where you moved this one from but there is another one here

Thanks for pointing that out. The other one is now closed.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
Thank you for noticing, Joanne. I moved my copy from the JDBC forum, of all places.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
I was mistaken; it wasn't JDBC, but Jobs discussion. Sorry about that.
 
GeeCON Prague 2014
 
subject: NoClassDefFoundError in a simple program