The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Finding main

Posted by Matt Gerrans on January 25, 2002 at 2:53 PM


> Whenever I try to use java.exe or javaw.exe with MS-DOS Prompt, I get a windows message from the Java Virtual Machine Launcher saying "Could not find the main class! Program will exit!". Originally I though because I had installed Borland's JBuilder and also the Java2 SDK from Sun's website that there was a conflict. So I uninstalled JBuilder. The message still came up, so I then uninstalled the SDK and JRE. I then re-installed the SDK. But the message is still persisting. It appears regardless of whether I switch to the directory that javaw.exe is in or not. Does anyone know the problem? I didn't restart the computer after the uninstall or the reinstall because I didn't think I needed to. Could that be the problem? Thanks for any help.
> Hiran

There are a few things that can cause this not-finding-main thing:


  1. Your prototype for main is wrong: missing static, static or void, not having an args String array (I forgot the [] part one time and it took a while to find).
  2. There is another class earlier in the classpath with the same name as the one you are trying to run, that doesn't have a main.
  3. Your class, or the current directory, is not in the classpath.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us