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

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

I think the reason is the version in which the class file was compiled and the version you are using now to run the class file is lower then that of the version used to compile it. Or you have more then 1 version of java installed:http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/UnsupportedClassVersionError.html ...how to fix;http://mynetsecurity.blogspot.com/2012/01/java-unsupported-class-version-error-ii.html and http://www.artima.com/forums/flat.jsp?forum=1&thread=158813 and this:http://stackoverflow.com/questions/2466828/java-lang-unsupportedclassversionerror-bad-version-number-in-class-file

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.

Please copy the console contents and paste it here.

so its this the reason

http://i.imgur.com/C1zqp.jpg

my javac and java version are different?? if so how to fix this

update to java 7:http://www.oracle.com/technetwork/java/javase/downloads/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 currently

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

i have jdk7u2 already installed

i have jdk7u2 already installed

The problem is i think you have both java 6 and 7 except the path being used to execute the jvm is the jdk 6, try changing your java path to java 7... make sure you have the jdk 7 and not just jre 7.. see here:http://stackoverflow.com/questions/5481964/exception-in-thread-main-java-lang-unsupportedclassversionerror-danbikel-pars and this:http://confluence.atlassian.com/display/DOC/Setting+the+JAVA_HOME+Variable+in+Windows and here:http://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7

Open a command prompt and enter: Path
It will print out the current value on the console and you can copy it here.

yeah i just changed my environmental settings in path but there was already 7 there

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:\>

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

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.

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

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

And that worked sir, thankyou for all your help :)

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.