Compiling/Running Project in Command Line: "Could not find main class" Error
I have a problem and I have looked at many places, including java-forums dot org slash "/new-java/2191-could-not-find-main-class-program-will-exit.html", but could not solve my problem (I have to type this way b/c I can't post links as a new member). I'd greatly appreciate your help.
I am using Eclipse for a project for a project with 5 packages and a bunch of classes and interfaces. The following Jar Files are showing up under my project name in Eclipse.
It's running fine in Eclipse, but for various reasons I have to compile and run it from the Windows command line. Compiling has been fine, I have just used
and so on.
javac directoryOfFirstPackage\*.java directoryOfSecondPackage\*.java
But when it comes to running the files, I am getting the a bunch of error lines and with
at the end.
Could not find the main class: SendAMessage. Program will exit
SendAMessage is the name of the class that I run in Eclipse and that runs fine. It has references to classes in its own package, as well as classes in the other four packages.
What I have tried:
1) I have added "C:\Sun\SDK\jdk\jre\bin", "C:\Sun\SDK\jdk\jre\lib", "C:\Sun\SDK\jdk\lib", "C:\Sun\SDK\jdk\bin" to the Path variable in Vista (My Computer > Properties > Advanced System Settings > Environment Variables) and when I type "path" in command line, my addenda show up. Nothing changes when I try to run.
2) I have copied all the .jar files I could find from the SDK directories above into the same folder with my main class. Nothing changes.
3) I have edited the .classpath file in the project directory. All the C:\ entries below are my additions. Didn't help...
<?xml version="1.0" encoding="UTF-8"?>
<classpathentry kind="src" path="src"/>
<classpathentry kind="jars1" path="C:\Sun\SDK\lib"/>
<classpathentry kind="jars2" path="C:\Sun\SDK\bin"/>
<classpathentry kind="jars3" path="C:\Sun\SDK\jdk\bin"/>
<classpathentry kind="jars4" path="C:\Sun\SDK\jdk\lib"/>
<classpathentry kind="jars5" path="C:\Sun\SDK\jdk\jre\bin"/>
<classpathentry kind="jars6" path="C:\Sun\SDK\jdk\jre\lib"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
I greatly appreciate your help.