This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
run javac version again... you can't get an invalid option and the message that you got. Basically, run both of these commands again and give us the output...
javac -J-version javac -version
EDIT: Now that I think about it, it is possible to have an old java compiler executed by a newer jvm -- which doesn't really make sense. By any chance, did you happen to install the JRE instead of the JDK? In there a "javac" program actually in the bin directory that you are in?
Henry [ April 09, 2008: Message edited by: Henry Wong ]
Originally posted by Srividhya Kiran: ...This is the message I get
C:\Java\jdk1.6.0_04\bin>javac -J-version java version "1.6.0_04"...
Interstingly, your current directory is "bin" here. When you got the response that -version is an invalid flag, your current directory was C:\Java\jdk1.6.0_04\bin\DirA. (I'm guessing that when you successfully ran my class PrintingOut, this was also under the bin directory.)
As Henry pointed out, you do not want to mix your own files and directories in with Java's bin content. As he also pointed out (and as Christophe agrees), this sounds like a path issue. To correct this, see step 4 of Sun's installation instructions for Windows. Note the following from these instructions...
PATH environment variable is a series of directories separated by semi-colons (;) and is not case sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.
You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored. If one is already present, update it to jdk1.6.0_<version>\bin.
I am fairly confident that your PATH variable includes an old JDK version (1.4 or earlier), and you should update this to point to your 1.6 bin directory. [ April 09, 2008: Message edited by: marc weber ]
Joined: Feb 17, 2008
Yes chirtophe you are correct. I understood what the problem is. In the bin directory compiler gave me the correct version 1.6. But under DirA where my program is, the version displayed is below:
C:\Java\jdk1.6.0_04\bin>javac -J-version java version "1.6.0_04" Java(TM) SE Runtime Environment (build 1.6.0_04-b12) Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
C:\Java\jdk1.6.0_04\bin\DirA>javac -J-version java version "1.4.2_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_16-b05) Java HotSpot(TM) Client VM (build 1.4.2_16-b05, mixed mode)
Now how should I change the version and compile.So I gave
invoke control panel -> go to system -> advanced -> select environment variables
Then in user variables and system variables check for variable PATH and the folderofjdk\bin be the first one or if previous version bin is in path replace it with the new one, do the same with the classpath variable too, prepend folderofjdk\lib\tools.jar;.; in the classpath.
create a separate folder outside jdk and store all your files there. As jdk\bin is in path, you'll be able to invoke javac and java commands from anywhere in your system.