Results 1 to 13 of 13
- 07-18-2012, 07:56 PM #1
Member
- Join Date
- Jul 2012
- Location
- Nigeria
- Posts
- 7
- Rep Power
- 0
Error: Could not find or load main class HelloWorld
pls how do i solve this error on my java am new here and am also new to leaning java am a computer science i really need to lean it
this are errors i get
Java Code:Microsoft Windows [Version 6.0.6002] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Users\hp>cd desktop C:\Users\hp\Desktop>cd java C:\Users\hp\Desktop\java>cd student files The system cannot find the path specified. C:\Users\hp\Desktop\java>student files 'student' is not recognized as an internal or external command, operable program or batch file. C:\Users\hp\Desktop\java>cd Student Files The system cannot find the path specified. C:\Users\hp\Desktop\java>cd StudentFiles C:\Users\hp\Desktop\java\StudentFiles>cd Ch02 C:\Users\hp\Desktop\java\StudentFiles\Ch02>cd Hello C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>cd Greetings.java The directory name is invalid. C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>greetings.java Error: Could not find or load main class C:\Users\hp\Desktop\java\StudentFiles\C h02\Hello\Greetings.java C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>java Greetings Error: Could not find or load main class Greetings C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>java HelloWorld Error: Could not find or load main class HelloWorld C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>
Last edited by DarrylBurke; 07-18-2012 at 09:55 PM. Reason: Removed annoying formatting
- 07-18-2012, 08:39 PM #2
Member
- Join Date
- Jul 2012
- Posts
- 55
- Rep Power
- 0
Re: Error: Could not find or load main class HelloWorld
I am not exactly sure what you are trying to do but to run command line prompts for your java program
1) get to directory of your .java files using cd
2) use javac nameOfProgram.java
this compiles it and creates a .class file
3) now use dir to see if the class file was created
4) now run java nameOfProgram
This should let you run your java program from command line
- 07-18-2012, 09:56 PM #3
Re: Error: Could not find or load main class HelloWorld
Why do they call it rush hour when nothing moves? - Robin Williams
- 07-18-2012, 10:27 PM #4
Member
- Join Date
- Jul 2012
- Location
- Nigeria
- Posts
- 7
- Rep Power
- 0
- 07-18-2012, 10:38 PM #5
Member
- Join Date
- Jul 2012
- Location
- Nigeria
- Posts
- 7
- Rep Power
- 0
Re: Error: Could not find or load main class HelloWorld
i tried again and got this error
c:\Program Files\javac>javac Greetings.java
Greetings.java:8: error: error while writing Greetings: Greetings.class (Access
is denied)
public class Greetings
^
1 error
- 07-18-2012, 10:40 PM #6
Re: Error: Could not find or load main class HelloWorld
First learn to use your OS. Once you have that down, get back to thinking about Java. When you do, go through Trail: Getting Started (The Java™ Tutorials)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 07-18-2012, 10:42 PM #7
Re: Error: Could not find or load main class HelloWorld
Why do they call it rush hour when nothing moves? - Robin Williams
- 07-18-2012, 10:42 PM #8
Member
- Join Date
- Jul 2012
- Posts
- 55
- Rep Power
- 0
Re: Error: Could not find or load main class HelloWorld
I am going to try with your code from before
Java Code:C:\Users\hp>cd desktop C:\Users\hp\Desktop>cd java C:\Users\hp\Desktop\java>cd StudentFiles C:\Users\hp\Desktop\java\StudentFiles>cd Ch02 C:\Users\hp\Desktop\java\StudentFiles\Ch02>cd Hello C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>//I AM ASSUMING THIS IS THE CLASS DIRECTORY WITH THE .JAVA FILE IN IT C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello> javac HelloWorld.java C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello> dir //MAKE SURE IT CREATED A .CLASS FILE C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello> java HelloWorld
- 07-18-2012, 11:29 PM #9
Member
- Join Date
- Jul 2012
- Location
- Nigeria
- Posts
- 7
- Rep Power
- 0
Re: Error: Could not find or load main class HelloWorld
Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\hp>cd desktop
C:\Users\hp\Desktop>cd java\StudentFiles
C:\Users\hp\Desktop\java\StudentFiles>cd Cho2
The system cannot find the path specified.
C:\Users\hp\Desktop\java\StudentFiles>cd Ch02
C:\Users\hp\Desktop\java\StudentFiles\Ch02>cd Hello
C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>j avac Greetings.va
error: Class names, 'Greetings.va', are only accepted if annotation processing i
s explicitly requested
1 error
C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>
C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>j ava
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See Java SE Documentation at a Glance for m
ore details.
C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>d ir
Volume in drive C has no label.
Volume Serial Number is E01E-0974
Directory of C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello
17/07/2012 01:45 <DIR> .
17/07/2012 01:45 <DIR> ..
12/10/2010 20:02 446 Greetings.java
12/10/2010 20:00 604 Greetings2.java
17/07/2012 06:32 186 HelloWorld.java
3 File(s) 1,236 bytes
2 Dir(s) 74,627,743,744 bytes free
C:\Users\hp\Desktop\java\StudentFiles\Ch02\Hello>
thats what i got
- 07-18-2012, 11:30 PM #10
Member
- Join Date
- Jul 2012
- Location
- Nigeria
- Posts
- 7
- Rep Power
- 0
Re: Error: Could not find or load main class HelloWorld
how will i know if it has created a .class file?
- 07-18-2012, 11:38 PM #11
Member
- Join Date
- Jul 2012
- Location
- Nigeria
- Posts
- 7
- Rep Power
- 0
Re: Error: Could not find or load main class HelloWorld
Hello i think i"ve got it let me try it again
- 07-18-2012, 11:43 PM #12
Member
- Join Date
- Jul 2012
- Location
- Nigeria
- Posts
- 7
- Rep Power
- 0
Re: Error: Could not find or load main class HelloWorld
yes i've got it thanks to u all i really appreciate.
- 07-19-2012, 07:14 AM #13
Re: Error: Could not find or load main class HelloWorld
... did your school not teach you how to use a command line? I have never taken classes, but I have taught a few and that is usually what I teach first. Maybe I am doing something wrong.

How do you know if you wrote a paper in Microsoft word and it saved as a .doc file. The answer, you check the folder you saved it in. Same with compiling. Check the folder you compiled in and there should be a file(s) with the name of the file you just compiled. Another way to know, is that javac will return without any errors. If you just get a new line in the command prompt, you will know something went really RIGHThow will i know if it has created a .class file?
, or REALLY, REALLY, WRONG! .gif)
My suggestion before jumping into Java, as DarrylBurke, is to learn how to use your OS by learning how things work on your OS such as the command-line. Get so comfortable with it that you will use it for EVERYTHING. Try jumping into Linux and DO NOT INSTALL GUI. Get a good book that explains how to use the *nix command lines and learn from there. That is how I learned how to use a terminal.
Happy Learning!!My API:Java Code:cat > a.out || cat > main.class
Similar Threads
-
Error: Could not find or load main class HelloWorld
By grejsimojs in forum New To JavaReplies: 8Last Post: 07-11-2012, 10:27 PM -
Error: Could not find or load main class
By Tybald in forum EclipseReplies: 5Last Post: 05-28-2012, 11:22 AM -
Error: Could not find or load the main class build.jar
By Stoyicker in forum New To JavaReplies: 2Last Post: 05-24-2012, 09:58 PM -
Please help! Cannot find or load main class error
By BenH in forum New To JavaReplies: 3Last Post: 12-09-2011, 03:51 AM -
Error: Could not find or load main class
By ITSlave in forum New To JavaReplies: 4Last Post: 09-15-2011, 09:47 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks