• Post Reply Bookmark Topic Watch Topic
  • New Topic

Path for javac problem  RSS feed

 
Daniel Mikkelsen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey

I recently unistalled my OS (win7), and now I can't seem to set the path properly (the javac -version command doesn't work)

I've followed this guide http://www.coderanch.com/how-to/java/how-to-create-java-program which I did last time without a problem.

I've checked if the javac.exe is in the bin which it is: C:\Program Files\Java\jdk1.0.8_11\bin\javac.exe

I've restarted command promt, and, afterwards, also my PC without any luck.

Maybe some of this will be useful in helping me out:

C:\Users\Dingo>echo %path%
%JAVA_HOME%\bin;C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
;C:\Windows\System32\WindowsPowerShell\v1.0\

C:\Users\Dingo>where java
C:\Windows\System32\java.exe

C:\Users\Dingo>java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) Client VM (build 25.11-b03, mixed mode)

C:\Users\Dingo>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your JAVA_HOME environment variable set to ?
It needs to be set to C:\Program Files\Java\jdk1.0.8_11

Or, if some other program needs it to be set to the location of your JRE, you need to add C:\Program Files\Java\jdk1.0.8_11 to your PATH environment variable.
 
Daniel Mikkelsen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JAVA_HOME environemtn variable is set to C:\Program Files\Java\jdk1.0.8_11

Didn't quite understand the second thing you asked for?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A path is a list of directories the OS looks in. your first directory is "%JAVA_HOME%\bin;", where the first piece is a variable.

It is possible <something else> needs %JAVA_HOME% to be set how it is, and changing it would break something else.

So, you can always explicitly put any directory you want in your PATH...so you can simply add "C:\Program Files\Java\jdk1.0.8_11\bin" as another one in the list - make sure it is preceded by a semi-colon if you add it at the end
 
Daniel Mikkelsen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, think I got that

But I can't get it to work

I've change the path under System variables to:
C:\Program Files\Java\jdk1.0.8_11\bin;%JAVA_HOME%\bin;C:\Program Files\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ (I added the first part)

It still doesn't function
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Mikkelsen wrote:
But I can't get it to work

I've change the path under System variables to:
C:\Program Files\Java\jdk1.0.8_11\bin;%JAVA_HOME%\bin;C:\Program Files\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ (I added the first part)

It still doesn't function


First of all, this is *not* something that you want to pay trail and error with. If you mess up your system path, you can break a lot of installed applications in your environment (and as fred already mention, you may have a dependency on another Java version in your environment) ... be real careful here !!

Regardless, "it still doesn't function" doesn't tell us anything. Please give more context (http://www.coderanch.com/how-to/java/TellTheDetails).

Henry
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Mikkelsen wrote:I've change the path under System variables to:
C:\Program Files\Java\jdk1.0.8_11\bin;%JAVA_HOME%\bin;C:\Program Files\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ (I added the first part)

It still doesn't function

Did you open a new command prompt to test it in ?
If yes, then try typing
"C:\Program Files\Java\jdk1.0.8_11\bin\javac" -version
and tell us what that produces. Make sure you keep the double quotes.
 
Daniel Mikkelsen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joanna:
Yeah, I closed and opened the command promt.

When I try that command it gives me this:
C:\>"C:\Program Files\Java\jdk1.0.8_11\bin\javac" -version
The system cannot find the path specified.

Henry:
When I say it doesn't funtion, I mean I continue to get the following:
C:\Users\Dingo>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.
I'll try to be more specific from now on ;)
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you uninstall and re-install the jdk in a different directory?

C:\Users\Dingo>where java
C:\Windows\System32\java.exe

The java.exe in jdk is not listed here. I am sure if you issue >where javac, it won't also list the jdk directory.
So my advice is uninstall and re-install in a different directory.
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think uninstalling Java will help. You have managed to find a java.exe in System32. Are you on a 32‑bit machine? What happens if you write java -version? Do you get 1.8.0_11? If not (and this will be particularly bad if the Java version is 1.7 or earlier) you can have problems if your javac tool is newer than the java tool.
Are you really writing 1.0.8? It should be 1.8.0 Please read this, including the link about how to quote environment variables.
Please use Windows Explorer or whatever it is called nowadays to confirm that the directory Program Files\Java\jdk1.8.0_11\bin exists and that it contains java.exe and javac.exe (It usually contains about 15 or 20 files).

And if you are really writing 1.0.8 rather than 1.8.0 that might be the source of your troubles.
 
Daniel Mikkelsen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul:
I tried uninstalling jdk, installing it in a different folder, and changed the path to the new folder. However, I still get this:


I have installed it in my Java folder again.

Campbell:
Yes, I'm on a 32-bit machine.

Yes, I got version 1.8.0_11, viz.


I have confirmed using Windows Explorer that both java.exe and javac.exe exist in Program Files\Java\jdk1.8.0_11\bin, viz.


I just found the problem! When I tried to create a .txt of my %path% it said access denied... So, I tried 'run as admin.', and now javac -version works!


Thanks for your effort and help, ranchers! I'm happy to get back on the java-programming track.

 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never thought of that one. Well done sorting it out
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!