I have never had this problem before.

I code all my applications in the Eclipse IDE, and they all work fine there.
But if I go into the bin and use a batch file, with 'java ClassName' it gives me an error about not finding the main class.
I have never had this problem in the past, so I know the command is correct and all that, and I havn't updated Java recently.

Anybody have any suggestions?

Please copy and paste the full text of the error message. There could be important info there.
Is the class in a package?

Exception in thread "main" java.lang.NoClassDefFoundError: Servient
Caused by: java.lang.ClassNotFoundException: Servient
        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: Servient.  Program will exit.
Press any key to continue . . .

No, they are not in any packages.
Like I said, the same exact files and everything worked like 2 weeks ago. They've just been sitting on my thumbdrive. And today I plug it back in, run the batch file, and it stopped working.
I thought it was just a code error at first, because the address the bot connects to changed. But I tested other applications on the same thumbdrive and they all spat out the same error.

*edit: Also applications on my hardrive as well, not just the thumbdrive.

Edited 6 Years Ago by Virux: n/a

NoClassDefFoundError: Servient

I need a bit more info:
Where is the class file Servient.class?
What command do you issue? What's in the batch file?
What directory are you in when you execute the batch file?
Is there a drive letter used in the batch file? >> Your stick is on different drive.

Can you cd to the folder with the class files, issue a dir command to display the contents of the folder and then issue the java command?
Then copy and paste here all that's shown on the console.

Here's what I get when there is no class file:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\Norms\Norms Tools>java asdf
Exception in thread "main" java.lang.NoClassDefFoundError: asdf
Caused by: java.lang.ClassNotFoundException: asdf
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: asdf. Program will exit.

D:\Norms\Norms Tools>

Edited 6 Years Ago by NormR1: n/a

Nah. lol, I knew it was none of that.

Turns out it was Quick Time. Quick Time messed everything up for some reason.
I uninstalled it about a week ago because it kept trying to take over my Flash players online.
And I installed it again a while ago because somebody sent me a .mov

So I guess that's a pretty crazy reason, but whatever. That's what it was in case anybody else runs into this same thing.

This question has already been answered. Start a new discussion instead.