File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Class Names - Windows XP Problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Class Names - Windows XP Problem?" Watch "Class Names - Windows XP Problem?" New topic
Author

Class Names - Windows XP Problem?

Andrew Babaian
Greenhorn

Joined: May 16, 2002
Posts: 25
I'm a little confused. I can compile and run:
public class test
{
public static void main(String[] args)
{
System.out.println("hello world!");
}
}
but I can compile, but can't run:
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("hello world!");
}
}
I get this exception:
Exception in thread "main" java.lang.NoSuchMethodError: main
I also can compile but can't run:
public class helloworld
{
public static void main(String[] args)
{
System.out.println("hello world!");
}
}
I get this exception:
Exception in thread "main" java.lang.NoClassDefFoundError: helloworld (wrong name: HelloWorld)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
What gives?
Thanks
Andrew
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
Make sure that your "HelloWorld" class is in a file named "HelloWorld.java", and your "helloworld" class is in a file named "helloworld.java". Case matters.
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

...Except to Windows file names. The OS sometimes gets a little bit fnicky about actually recognizing a change to a file name if the only thing that you change is the case. You may need to copy the file to another directory with the new case, delete the old file, and then move the copied file to the directory where you want it.
Basic summary: Java cares about case, but Windows doesn't.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Names - Windows XP Problem?