Results 1 to 6 of 6
- 12-10-2012, 02:34 AM #1
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
could not find or load main class HelloWorldExample
Plz help
I have set the (user variable for owner)path correctly ie (C:\Program Files\Java\jdk1.7.0_09\bin;)
I have altered the system variable class path. i wonder if that is why my program is not locating the main class.
i deleted some stuff then added........or messed it up.
now it is C:\Program Files\Java\jdk1.7.0_09\lib
i do not know how the class path should be
even the command java -cp . HelloWorldExample works but not java HelloWorldExample
(code compiles but dosent excecute)
my working directry is c:\javaprograms> where i have stored the HelloWorldExample.java code and the class file also is in the same folder.
my code is
public class HelloWorldExample{
public static void main(String args[]){
System.out.println("Hello World !");
}
}
- 12-10-2012, 03:41 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: could not find or load main class HelloWorldExample
You can just run your HelloWorldExample by executing command java HelloWorldExample. Just make sure that java command is executable from your command line.
Website: Learn Java by Examples
- 12-10-2012, 03:43 AM #3
Re: could not find or load main class HelloWorldExample
Moved from a staff only section.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-10-2012, 03:47 AM #4
Re: could not find or load main class HelloWorldExample
The "Could not find or load main class" error comes from the Java executable.
The real issue is that a system CLASSPATH is set, one that does not include the current working directory. tafjava, either get rid of the system CLASSPATH (prefereable) or prepend ".;" to it.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-10-2012, 05:37 AM #5
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
- 12-10-2012, 05:45 AM #6
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: could not find or load main class HelloWorldExample
Just as DB pointed out in his post earlier. You should remove your system classpath. You can see the current value of classpath using the echo %CLASSPATH% from you command prompt. Then execute it again using java -cp . HelloWorldExample.
Website: Learn Java by Examples
Similar Threads
-
could not find or load main class | cannot manually locate class file
By Holden Caulfield in forum New To JavaReplies: 1Last Post: 11-29-2012, 09:46 AM -
Could not find or load main class
By kkid in forum New To JavaReplies: 4Last Post: 10-15-2012, 04:47 AM -
Error: could not find or load main class
By sloppygecko in forum New To JavaReplies: 3Last Post: 08-08-2012, 03:11 PM -
Error: Could not find or load main class
By Tybald in forum EclipseReplies: 5Last Post: 05-28-2012, 11:22 AM -
Please help! Cannot find or load main class error
By BenH in forum New To JavaReplies: 3Last Post: 12-09-2011, 03:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks