Results 1 to 6 of 6
- 08-22-2009, 11:22 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 26
- Rep Power
- 0
Can't run my java program through cmd prompt
hey, i've seen this error on quite a few forums but I still can't seem to fix it.
I've changed the PATH environment variable and it's compiling fine with javac.
i've set the class path like this: set CLASSPATH=.;C:\Program Files\Java\jdk1.5.0_15\lib
and done echo %classpath% to verify that it was set.
I've gone to the directory where the class files are located and after compiling successfully with
javac, i try running the code and no matter what, i get that error!!! Can someone please tell me what i'm doing
wrong and how i can fix this. Like i've even gone
java -classpath . ReadStandardInput
and it still hasn't worked, i still get same error, oh btw ReadStandardInput is just the name of my java file.
This is the full error message from command prompt:
C:\olddata\Documents and Settings\Chad\Chad\Uni Semester 2 2009\COMS3200\Data2\s
rc\General>java -classpath . ReadStandardInput
Exception in thread "main" java.lang.NoClassDefFoundError: ReadStandardInput (wr
ong name: General/ReadStandardInput)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: ReadStandardInput. Program will exit.
C:\olddata\Documents and Settings\Chad\Chad\Uni Semester 2 2009\COMS3200\Data2\s
rc\General>
I'd really appreciated if someone could help me fix this cos i really don't know what to do now.
Thanx,
Epically frustrated guy, cry++;
- 08-22-2009, 03:02 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
First of all, you've to check that class-path setup is correct. There is an easy way to do this, open the command prompt and type the command javac and hit enter. If you get a list of some options and explanations, congratz you've setup the class-path correctly.
More looking at your error it's something wrong with your Java code. Can you show your code? This error can cause lots of things.
-
- 08-22-2009, 03:07 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 05-15-2013, 07:25 PM #5
Member
- Join Date
- May 2013
- Posts
- 1
- Rep Power
- 0
Re: Can't run my java program through cmd prompt
change your dirctry to the dirctory wher ur compiled java program is risiding
using
simple command promput command CD path
example if u stored ur java file in C:\test\helloworld.java then when u compile java stores the compiled file in the same dirctry then to run
chnage the dirctry using cd c:\test then type
at
c:\test type java your java file hit return it should run
otherwise check your class name
good luck
check your class name and
- 05-15-2013, 08:34 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
clear screen prompt using java code
By krunalpatel1410 in forum Advanced JavaReplies: 9Last Post: 04-04-2009, 12:47 AM -
how to run windows command prompt in java parogram ?
By indikasampath2000 in forum AWT / SwingReplies: 4Last Post: 12-16-2008, 06:51 AM -
Is there any way to run java file through command prompt of .jar
By sachin.parnami in forum New To JavaReplies: 2Last Post: 12-03-2008, 01:24 PM -
accessing command prompt using java (netbeans)...
By kureikougaiji in forum New To JavaReplies: 6Last Post: 06-27-2008, 03:01 PM -
problem when I try to compile a program from command prompt
By osval in forum Advanced JavaReplies: 2Last Post: 08-06-2007, 09:16 PM


LinkBack URL
About LinkBacks


Bookmarks