Command Prompt compiling error help
http://i.imgur.com/iwNHY.jpg
i already set a path for jdk and etc, it worked before but now it doesnt work
the code works on ecclipse so the code is correct but i have to learn how to compile using command prompt
check out this image i get this same error i do not know why, is it because of my classpath or something
doit(a batch file) is basically java -cp .;c:/cos210 edu.mccc.cos210.roach.RoachMotel
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
Here's how to copy the command prompt so it can be posted allowing copy and paste of the contents into further comments.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
Please copy the console contents and paste it here.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
update to java 7: http://www.oracle.com/technetwork/ja...ads/index.html .... the highest version can run all other lower versions, your error might be because the java version your class file was compiled with is/was higher then the one you are running
But i already have jdk kit installed and norm1
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Nipa>cd \
C:\>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
C:\>javac -version
javac 1.7.0_02
C:\>javac -version
javac 1.7.0_02
C:\>cd COS210
C:\COS210>cd roach
C:\COS210\roach>compile
C:\COS210\roach>javac -cp .;c:/cos210 -Xlint -d . src/edu/mccc/cos210/roach/*.j
ava
C:\COS210\roach>doit
C:\COS210\roach>java -cp .;c:/cos210 edu.mccc.cos210.roach.RoachMotel
Exception in thread "main" java.lang.UnsupportedClassVersionError: edu/mccc/cos2
10/roach/RoachMotel : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown 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)
Could not find the main class: edu.mccc.cos210.roach.RoachMotel. Program will e
xit.
C:\COS210\roach>
this is what i have
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
i have jdk7u2 already installed
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
Open a command prompt and enter: Path
It will print out the current value on the console and you can copy it here.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
yeah i just changed my environmental settings in path but there was already 7 there
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
NormR1
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Nipa>cd \
C:\>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Sony\VAIO Startup Setting Tool;C
:\Program Files (x86)\Common Files\HP\Digital Imaging\bin;C:\Program Files (x86)
\HP\Digital Imaging\bin\;C:\Program Files (x86)\HP\Digital Imaging\bin\Qt\Qt 4.3
.3;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Java\jre7\b
in;C:\PROGRA~1\TIEDUC~1\TI-83P~1\UTILS;C:\Program Files (x86)\Google\Google Apps
Sync\;C:\Program Files (x86)\Google\Google Apps Migration\;C:\Program Files (x8
6)\Java\jdk1.7.0_02\bin
C:\>
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
yeah i just changed my environmental settings in path but there was already 7 there
was 6 in there at all? if so i'd suggest removing it
[edit] nevermind the above post you made answered me... then i unfortunately do not have a clue :S
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
You need two paths:
One for javac
one for java
Is there a java.exe program in one of the Windows folders? That location could be before the paths you added to the PATH variable which means it is found before the ones later on in the PATH.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
You need two paths:
One for javac
one for java
Is there a java.exe program in one of the Windows folders? That location could be before the paths you added to the PATH variable which means it is found before the ones later on in the PATH.
i found the java.exe which was located C:\Windows\System32 so do i add this in path
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
No. That is the problem. That java.exe program is the older one and is the one that is being executed. If you look at the PATH variable's contents you'll see C:\Windows\System32 comes before the paths you added on.
A suggestion: You can try removing that program by renaming it to java_OLD.exe and see if the system will find the java.exe file from the PATH that you added. If there are no problems executing java programs (test jar files also) you can leave it there or delete it???
If there are problems, rename it back to its original name: java.exe
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
And that worked sir, thankyou for all your help :)
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
I wonder if something has changed with the java install process?
If you installed a 1.7 version of the JRE, the java. exe program should have been replaced.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
I wonder if something has changed with the java install process?
If you installed a 1.7 version of the JRE, the java. exe program should have been replaced.
In my windows 7 there is no javac.exe present in system32 folder so it must have changed its now in the java folder in program files
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
The JDK install didn't put the javac.exe file anywhere. I think it was just the JRE installs that put the java.exe file in a Windows folder.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656