Results 1 to 2 of 2
- 11-05-2011, 11:01 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 14
- Rep Power
- 0
Cannot compile "Hello World"; Cannot find or load main class
Hello, I am new to Java...so new, in fact, than I can't even get "Hello World" to run.
At first, when I tried to run the class file, the console window flashed, so I wrote a batch file that would compile the .java file and a separate one that would run the .class file. This sort of worked. It ran, and the console screen didn't close immediately. However, I'm getting a very annoying error message now:

compile.bat:
run.bat:Java Code:javac HelloWorld.java pause
HelloWorld.java:Java Code:java HelloWorld.class pause
Java Code:public class HelloWorld{ public static void main(String[] args) { System.out.println("Hello World"); } }

I have already done a google search, but the only thing I can find on it is about .jar files. Can someone please help me?
- 11-06-2011, 12:26 AM #2
Senior Member
- Join Date
- Aug 2011
- Posts
- 248
- Rep Power
- 2
Re: Cannot compile "Hello World"; Cannot find or load main class
I can't see why the following code causing errors.
I would reccomand using eclipse as a workspace, that would simplfy alot of things definitely if you are new to this language, Java IDE's
TIP: don't write that way, it's very confusin and unorginized.
Here are two common ways to do that:
Java Code:public class HelloWorld{ public static void main(String[] args) { System.out.println("Hello World"); } }Most of the people code on the first exmaple style, but I prefer the second one.Java Code:public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }
It's up to you, just a tip :DLast edited by tnrh1; 11-06-2011 at 12:29 AM.
Similar Threads
-
"could not find or load main class"
By questionortwo in forum New To JavaReplies: 4Last Post: 09-30-2011, 02:27 AM -
"Could not find the main class" when omitting "-jar"
By b0rt in forum Advanced JavaReplies: 11Last Post: 08-18-2011, 10:54 PM -
"Could not find the main class" for Linux Command Line Compile
By tetelee in forum New To JavaReplies: 3Last Post: 08-25-2010, 10:21 AM -
"Could not find the main class: comparisonDemo.class. Program will exit."
By ziisrick in forum New To JavaReplies: 6Last Post: 05-18-2010, 05:11 PM -
Compiling/Running Project in Command Line: "Could not find main class" Error
By Yasemin Gokce in forum New To JavaReplies: 1Last Post: 06-30-2009, 02:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks