"Javac" doesn't work correctly on Windows 10 - java

the problem is that I upgraded to Windows 10 and now I'm installing my tools to programming and now that I installed the JDK 7 of Java, when I try to use in the cmd the command:
- "javac"
The result of this is: "javac" is not recognized as an internal or external command...
But I was edited the PATH with the correct link of jdk, because when I use "java", it is ok.
Now, I tried in the console with this command: PATH=%PATH%;"C:\Program Files\Java\jdk1.7.0_79\bin"
And when I executed the command "javac" it works, but now, when I open other console, it doesn't work, or when I restart the console, this command is not recognized.
What could be the problem?

java is part of the JRE, not the JDK.
You need to add the JDK bin to the system PATH, in
"Control Panel" | System | Advanced | "Environment Variables"

Her's how I configure System variable on Windows 10 :

I am totally new to java and spent hours trying to get the problems with PATH and CLASSPATH worked out. There was one person who said to restart the command prompt after you modify the environment variables; that was it for me. While you are testing different configurations, make sure to relaunch the command prompt before testing. It seems like there are at least 2 different ways of setting this up. I went with the following:
1) In System Variables, add
JAVA_HOME = c:\program files (x86)\java\jdk1.8.0_121
2) In System Variables, add the following to existing Path...
%JAVA_HOME%\bin
That's it.
No need for quotes around anything. No double forward slashes or anything else. I think it would also work if I removed the java_home variable and just listed the explicit path to bin in the PATH variable, but I'm not touching it again now that it finally works.

After adding C:\Program Files\Java\jdk1.8.0_73\bin to the system variables I turned off my command prompt and opened another one. Then it worked.

Maybe a bit late, but i had same problem.
Click on "Move up" button for Java path and move it at top.
It fixed problem for me

just add C:\Program Files\Java\jdk1.7.0_80\bin as the path in environmental variables. no need to add java.exe and javac.exe to that path. IT WORKS

I added below Path in environment variable
;%JAVA_HOME%/bin instead of %JAVA_HOME%\bin
in my case , it fix the problem

I had the same issue on Windows 10 - the java -version command was working but javac -version was not. There are three things I did:
(1) I downloaded the latest jdk (not the jre) and installed it. Then, I added the jdk/bin path tan o environment variable. In my case, it was C:\Program Files\Java\jdk-10\bin. I did not need to add the ; for Windows 10.
(2) Move this path to the top of all the other paths.
(3) Delete any other Java paths that might exist.
Test the java -version and javac -version commands again. Voila!

For some reason it worked for me to add quotation marks to the path folder on windows 10. not C:\Program Files\Java\jdk 1.8.0_111\bin, but "C:\Program Files\Java\jdk 1.8.0_111\bin".

now i got it finally! make sure that there are no spaces before and after the path and put the semi-colon on both sides without spaces

The PATH is for current user, instead you can add a CLASSPATH and below link would help you more PATH and CLASSPATH

I added below Path in environment variable
C:\Program Files\Java\jdk1.8.0_91\bin
and then compiled the program but got the error then I restarted the system and again compiled the program
This time it worked :)

Add java path to environment variables and move it to the top of all the paths available there. It worked for me.

To be sure about your path, you can use double quotes " to locate the path or if you are in Windows, you can browse to path to select "C:\Program Files\Java\jdk1.8.0_121\bin" folder.

in the search window type 'environment variables' this should give you a link to editing the variables. On the variables editing page there is an upper section and a lower section in the lower section add NEW,type path C:\Program Files\Java\jdk-10\bin this worked great for me and it finds the compiler all the time.

Kind of beating a dead horse now but, I want to clarify one thing that may not be quite so obvious. Yes indeed you need to edit the PATH environment variable as already stated many times. The key for me was to edit the PATH under SYSTEM variables. I had inadvertently edited the PATH under USER variables. Why did this matter? On my machine I have to log in as an Administrator to edit environment variables. So editing the User variables was not helping because I run the command prompt under my login (non-admin) account. Grrr!
Also, I found that closing the command prompt window, and re-opening it after the PATH variable update was required. Changing the order of the values, adding semi-colons, etc. didn't make a difference for me.
Cheers

If you have set all PATH variables correctly after installation, just restart it.
I had the same problem, I had also installed new Windows7 OS then I upgraded it to Win 10. Then i started setup necessary tools like IntelliJ, Java jdk,jre, eclipse so on.
In cmd, java -version worked but javac compiler got unrecognized. I checked and all good, the files in the folders, path are correct and so on.
I restarted and checked it again in cmd ,it worked.

what I did is:
I typed ; accidentally in front in the path variable and then hit OK, after this if I again edit it was nowhere going to the same page as earlier, it opened a new page as defined for user variables and then I was able to remove double quotes in front of the PATH VARIABLE.
Everything worked fine then. :)
Did it just now.

Add
PATH = C:\Program Files\Java\jdk1.8.0_66\bin
in Advanced system setting. Then Choose Environment Variable.

for windows 10 Users Use Java path( JDK Bin location) AS "C:\Program Files\Java\jdk-9.0.1\bin" it will work.

Points to remember, do as the image shows. Move the highlighted bar up using move up button, this will help.

Related

Why can't Java open the jvm.cfg file? [duplicate]

After years of working OK, I'm suddenly getting this message when trying to start the JVM:
Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'
I tried uninstalling, and got a message saying a DLL was missing (unspecified)
Tried re-installing, all to no avail.
At the same time, when trying to start Scala I get:
\Java\jdk1.6.0_25\bin\java.exe was unexpected at this time.
Checked %JAVA_HOME% and %path% - both OK
Can anyone help?
I checked my environment variables - JAVA_HOME & PATH and they all refer to C:\java. So this was bit frustrating. After sometime I found that the default installation also copied java.exe, javaw.exe and javaws.exe to C:\Windows\System32 (i.e. uninstall of JRE didn't go well). I just removed them and voila, I'm back on track. That annoying error is no longer popping.
This works for me
So, If exists, remove java.exe, javaw.exe and javaws.exe from System32
put %JAVA_HOME%\bin at the begin of PATH.
Might be a slightly different cause, but that second issue occurs for me in scala 2.9.0.1 on Win7 (x64), though scala-2.9.1.final has already resolved this issue mentioned here:
\Java\jdk1.6.0_25\bin\java.exe was unexpected at this time.
My %JAVA_HOME% set to a path like this: c:\program files(x86)\Java\jdk...
Note the space and the parentheses.
If you change line 24 in %SCALA_HOME%\bin\scala.bat from:
if exist "%JAVA_HOME%\bin\java.exe" set _JAVACMD=%JAVA_HOME%\bin\java.exe
to
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
It works fine. Note the quotes around the set command parameters, this will properly enclose any spaces and 'special' characters (eg: spaces and parentheses) in the variable's value.
Hope this helps someone else searching for an answer.
I had a slight different solution to this problem. my PATH and JAVA_HOME were pointing to JDK12 in
C:\Program Files\Java
but execution of the command:
Java -version
gave the error:
Error: could not open `C:\ProgramFiles\Java\jre1.8.0_212\lib\amd64\jvm.cfg'
I had to delete a folder of executables (Java.exe, javaw.exe etc.) in a different directory than System32, as other answers here and blog posts have suggested. Instead I found the problem lied with executables found in:
C:\Program Files\Common Files\Oracle
as there was nothing Java related in
C:\Windows\System32
If you're having this issue and nothing is in System32, check this "common files" directory mentioned above for an oracle directory and delete it.
After, your PATH references should work fine!
I had the same problem: I have a 64 bit Windows and when I typed "java -version" in CMD-Console i received the same Error message.
Try to start a 64bit-cmd(C:\Windows\SysWOW64\cmd.exe) and you will see, it works there ;)
C:\ProgramData\Oracle\Java\javapath
I took a back up of the files in it and removed those files from there. Then I opened a new cmd prompt and it works like a charm.
If this was working before, it means the PATH isn't correct anymore.
That can happen when the PATH becomes too long and gets truncated.
All posts (like this one) suggest updating the PATH, which you can test first in a separate DOS session, by setting a minimal path and see if java works again there.
Finally the OP Highland Mark concludes:
Finally fixed by uninstalling java, removing all references to it from the registry, and then re-installing.
scary ;)
I thought I will share how I resolved the same issue "Error Could not open lib\amd64\jvm.cfg". I found the Java run time Jre7 is missing amd64 folder under lib. However, I have 1.7.0_25 JDK which is having jre folder and also having amd64.
I moved the original contents of jre7 folder to a backup file and copied everything from 1.7.0_25\jre.
Now I am not getting this error anymore and able to proceed with scene builder.
The Java 7 install on my work PC broke after a patch was forced out to us, giving this error any time you tried to run a Java program. Somehow the entire 'lib' subdirectory of the Java 7 install vanished! Might have been related to having both Java 6 and Java 7 installed -- the 'jre6' directory still had everything there.
In any case, I fixed it by uninstalling both Java 6 and Java 7 and reinstalling just Java 7. But if the file it's complaining about is actually there, then you're likely having a path issue as described in some of the other answers here.
Had suddenly the same Problem, from one day to another eclipse said
Failed to load the JNI shared library "C:/JDK/bin/client/jvm.dll"`.
after trying to run java on the console
Error: could not open `C:\WINDOWS\jre\lib\amd64\jvm.cfg'
now i just deleted the whole directory
C:\WINDOWS\jre
and everything worked again... i don't know there this jre came from, i hope it was not a virus
Another workaround is using shortpath in windows:
open windows command console using cmd.exe
goto c:\
type command> dir program* /x
it should display as short path like: PROGRA~2
so C:\PROGRA~2 is same as C:\Program Files (x86)
in your JAVA_HOME replace path to :
C:\PROGRA~2\Java\jre7
This should work in windows 64 environment as it worked for me in win7 64bit version.
I have changed the java installation path from c:\Program Files (x86)\java to another folder like c:\java\jdk1.7 and updated the %Java_HOME% and path values accordingly,it worked.
example
%JAVA_HOME% = C:\java\JDK1.7
path-C:\java\JDK1.7\bin;
I had the same problem in Eclipse and I fixed it by changing the JRE from 64 bit to 32 bit:
Window > Preferences > Java > Installed JREs > Add... > Next > Directory > select "C:\Program Files (x86)\Java\jre1.8.0_65" instead of "C:\Program Files\Java\jre1.8.0_60"
I had a similar problem (trying to start a Jenkins slave agent on Windows) on Windows 2008R2, Java 1.7.0_15
I had two situations that contributed to the problem and that changing both of them fixed it:
1) Installing Java in a unix-compatible path (changing from c:\Program Files\... to c:\Software\...); I don't think this directly affected the problem described in this thread, but noting the change;
2) Running Java not through a shortcut. It originally failed with a shortcut, but re-running from the direct executable (C:\Software\Java...\bin\java) worked.
Reinstalling java didn't help me. But the trick to put the JAVA_HOME variable at the beginning of the env-vars. The problem occoured after an upgrade from jdk1.7.0_11 to jdk1.7.0_13
I had this problem after updating your java. The best way to solve this problem is just go to your c:/ProgramFiles/Java folder. There you will find two jre folders one is as jre.your version and other with exactly like jdk folder. Try to remove jre.1.your version folder. There you go your problem is solved. Hope this might help. It's worked for me.
Typically it because of upgrading JRE.
It changes symlinks into C:\ProgramData\Oracle\Java\javapath\
Intall JDK - it will fix this.
Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'
Looking # it the issue of post install script is there and getting propagated since I am using update jdk8 1.8.0_191 since issue occurred with me after installing update of java and which was happened automatically.
Error: could not open `C:\Program Files\Java\jre1.8.0_191\lib\amd64\jvm.cfg'
This will be never ending in this case and need to do workaround like changing path's manually.
Delete the jars under system32 for windows.
Delete the jars under C:\Program Files\Common Files\Oracle
Edit the environment variable set JAVA_HOME and SET PATH to bin
I have solved this issue by deleting the Oracle folder from Program Data. And also delete the oracle java path associated with that folder from environment variables.
I kept variable name as "Path" but it did not work after changing it to "PATH"
started working for me.
variable name: PATH
variable value: C:\Program Files\Java\jdk-19\bin
this will work.
It wasn't in the path. Finally fixed by uninstalling java, removing all references to it from the registry, and then re-installing. None the wiser, but back working again. Thanks all #Highland Mark- Can you tell me the process to removing references from registry. I tried all possible way people mentioned here, nothing worked.
If you have downloaded several Jdks you have to delete all except of the JDK you want to use!

setting issue of JAVA_HOME and JAVA_PATH

I have been using Eclipse to develop java program on a windows 7 machine. It works. I also typed "java" from the command prompt, it also shows the help message. In other words, I think Java was correctly installed on this machine. However, when I open the "environmental variable" setting on this machine, I cannot find either "JAVA_HOME" setting and "JAVA PATH" setting. What is the problem of this?
Java also copies java.exe and javaw.exe under C:\Windows\System32, there's where your java is running from.
You can confirm that by using where commmand:
On my win7 machine:
>where java.exe
C:\Windows\System32\java.exe
Some environment variables are defined at machine level and some are defined (and overwritten) at user account level. Just do following in windows cmd prompt:
c:\echo %PATH% or just type c:\path
and verify the output.
You can also verify java home path by writing a simple Test class like following:
public class Test {
public static void main(String[]s){
System.out.println(System.getProperty("java.home"));
}
}
There are multitudes of links to be fond on Google regarding how to solve this in Windows. These environment variables typically do not get setup by default when installing java.
Here are some 10 second finds with with answers:
How to set java_home on Windows 7?
Setting the JAVA_HOME Variable in Windows
Installing Java on Windows 7 and setting-up the JAVA_HOME
Check you PATH variable in Environment Variables. It must be set to jreInstallation/bin. Windows does not pick up java command from JAVA PATH, it picks java command from PATH variable.
Also note that once you install JDK, path is not set by installation to jdkInstallation/bin, you need to set it up explicitly.So unless you set the path to jdkInstallation/bin, javac wont be recognized.
Check your path variable in windows environmental variables. At least Java path should be there .
It may looks like this.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Java\jdk1.7.0\bin
You should set path and classpath variables.
Here's the link you can follow for step by step instructions.
[http://abodeqa.wordpress.com/2012/08/11/how-to-set-path/][1]
With Java, Groovy, Git, Heroku, Maven, and many other projects, what I always do is this:
1. Unzip the software package into a directory, for example:
C:\AeroFS\Java\jdk1.7.0_25
C:\AeroFS\Groovy\groovy-2.0.5
2. Create a HOME variable, such as JAVA_HOME or GROOVY_HOME that points to the
above locations.
3. Put these in your default system path by editing your PATH variable and
adding %JAVA_HOME%\bin and %GROOVY_HOME%\bin to the end of your PATH. In
the case of JAVA_HOME only, you might want to put it at the beginning of
the PATH to override the java.exe that rests in the WINDOWS directory
location.

I'm trying to set my JAVA_HOME path to use my javac.exe?

I'm on Windows 7 and I'm trying to set my JAVA_HOME path to use PhoneGap on android, when i create a project using the command line "cmd" it tells me that it can't find javac.exe? although i'm sure that I've set the variable right
here's my stuff:
Variable name: JAVA_HOME
Variable value: C:\Progra~1\Java\jdk1.7.0_17\bin
(I've also tried to use: C:\Progra~1\Java\jdk1.7.0_17\bin\javac.exe)
My javac.exe location on my laptop C:\Program Files\Java\jdk1.7.0_17\bin\javac.exe
and it still tells me that it can't locate the javac.exe
What I type to create the project and i meet this problem is this:
C:\Users\user>cd C:\Users\user\Desktop\phonegap-2.8.1\lib\android\bin
C:\Users\user\Desktop\phonegap-2.8.1\lib\android\bin>create.bat
Cannot locate javac.exe using the PATH environment variable.
Retry after adding directory containing javac.exe to the PATH variable.
Remember to open a new command window after updating the PATH variable.
Visit http://java.oracle.com if you need to install Java (JDK).
Also, i've tries restarting the windows and closing the command prompt and redownloading the JDK.
Thank You.
cmd is using the values from the PATH variable to locate javac :
set "PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_17\bin"
For other softwares (Tomcat, Maven, etc.) JAVA_HOME must indicate the root of your JDK :
set "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_17\"
No need to restart Windows. When using set the changes are taken immediately.
If you choose to modify those variables in the Control Panel, you have to close and relaunch cmd for the changes to take effect.
You have to add java
C:\Program Files\Java\jdk1.7.0_17\bin
Note that your path may be different.
to your environment variables and restart your console.
You can find how to set your variables here:
http://www.itechtalk.com/thread3595.html
Set the JAVA_HOME Variable
Right-click the My Computer icon on your desktop and select Properties.
Click the Advanced system settings. Click the
Environment Variables button. Under System Variables, click New.
Enter the variable name as JAVA_HOME.
Enter the variable value as the installation path for the Java Development Kit(C:\Program Files\Java\jdk1.7.0_17).
Click OK.
Click Apply Changes.
You might need to restart windows.
Set the JAVA_HOME environmental variable to
C:\Program Files\Java\jdk1.7.0_17
Press
Win + Break > Advanced System Settings > Environment Variables > System Variables
Modify/set JAVA_HOME to the above. (No need to restart)
I already had this error when I tried to create a new phonegap project for android but unfortunately I don't remember how exactly I have fixed this.
I don't know if you have followed the phonegap documentation so here is the link : new project, especially the part 3B (be careful about ; in your PATH).
If you don't know what to do now, maybe you should do it again step by step.
May be a little old, but since this is the first goolge result, I might as well add a little something.
You need to create the JAVA_HOME variable AND edit the PATH variable, adding ;%JAVA_HOME%\bin (with a ;) so cmd and some other apps can actually use javac and the rest of the tools

Running Java gives "Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'"

After years of working OK, I'm suddenly getting this message when trying to start the JVM:
Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'
I tried uninstalling, and got a message saying a DLL was missing (unspecified)
Tried re-installing, all to no avail.
At the same time, when trying to start Scala I get:
\Java\jdk1.6.0_25\bin\java.exe was unexpected at this time.
Checked %JAVA_HOME% and %path% - both OK
Can anyone help?
I checked my environment variables - JAVA_HOME & PATH and they all refer to C:\java. So this was bit frustrating. After sometime I found that the default installation also copied java.exe, javaw.exe and javaws.exe to C:\Windows\System32 (i.e. uninstall of JRE didn't go well). I just removed them and voila, I'm back on track. That annoying error is no longer popping.
This works for me
So, If exists, remove java.exe, javaw.exe and javaws.exe from System32
put %JAVA_HOME%\bin at the begin of PATH.
Might be a slightly different cause, but that second issue occurs for me in scala 2.9.0.1 on Win7 (x64), though scala-2.9.1.final has already resolved this issue mentioned here:
\Java\jdk1.6.0_25\bin\java.exe was unexpected at this time.
My %JAVA_HOME% set to a path like this: c:\program files(x86)\Java\jdk...
Note the space and the parentheses.
If you change line 24 in %SCALA_HOME%\bin\scala.bat from:
if exist "%JAVA_HOME%\bin\java.exe" set _JAVACMD=%JAVA_HOME%\bin\java.exe
to
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
It works fine. Note the quotes around the set command parameters, this will properly enclose any spaces and 'special' characters (eg: spaces and parentheses) in the variable's value.
Hope this helps someone else searching for an answer.
I had a slight different solution to this problem. my PATH and JAVA_HOME were pointing to JDK12 in
C:\Program Files\Java
but execution of the command:
Java -version
gave the error:
Error: could not open `C:\ProgramFiles\Java\jre1.8.0_212\lib\amd64\jvm.cfg'
I had to delete a folder of executables (Java.exe, javaw.exe etc.) in a different directory than System32, as other answers here and blog posts have suggested. Instead I found the problem lied with executables found in:
C:\Program Files\Common Files\Oracle
as there was nothing Java related in
C:\Windows\System32
If you're having this issue and nothing is in System32, check this "common files" directory mentioned above for an oracle directory and delete it.
After, your PATH references should work fine!
I had the same problem: I have a 64 bit Windows and when I typed "java -version" in CMD-Console i received the same Error message.
Try to start a 64bit-cmd(C:\Windows\SysWOW64\cmd.exe) and you will see, it works there ;)
C:\ProgramData\Oracle\Java\javapath
I took a back up of the files in it and removed those files from there. Then I opened a new cmd prompt and it works like a charm.
If this was working before, it means the PATH isn't correct anymore.
That can happen when the PATH becomes too long and gets truncated.
All posts (like this one) suggest updating the PATH, which you can test first in a separate DOS session, by setting a minimal path and see if java works again there.
Finally the OP Highland Mark concludes:
Finally fixed by uninstalling java, removing all references to it from the registry, and then re-installing.
scary ;)
I thought I will share how I resolved the same issue "Error Could not open lib\amd64\jvm.cfg". I found the Java run time Jre7 is missing amd64 folder under lib. However, I have 1.7.0_25 JDK which is having jre folder and also having amd64.
I moved the original contents of jre7 folder to a backup file and copied everything from 1.7.0_25\jre.
Now I am not getting this error anymore and able to proceed with scene builder.
The Java 7 install on my work PC broke after a patch was forced out to us, giving this error any time you tried to run a Java program. Somehow the entire 'lib' subdirectory of the Java 7 install vanished! Might have been related to having both Java 6 and Java 7 installed -- the 'jre6' directory still had everything there.
In any case, I fixed it by uninstalling both Java 6 and Java 7 and reinstalling just Java 7. But if the file it's complaining about is actually there, then you're likely having a path issue as described in some of the other answers here.
Had suddenly the same Problem, from one day to another eclipse said
Failed to load the JNI shared library "C:/JDK/bin/client/jvm.dll"`.
after trying to run java on the console
Error: could not open `C:\WINDOWS\jre\lib\amd64\jvm.cfg'
now i just deleted the whole directory
C:\WINDOWS\jre
and everything worked again... i don't know there this jre came from, i hope it was not a virus
Another workaround is using shortpath in windows:
open windows command console using cmd.exe
goto c:\
type command> dir program* /x
it should display as short path like: PROGRA~2
so C:\PROGRA~2 is same as C:\Program Files (x86)
in your JAVA_HOME replace path to :
C:\PROGRA~2\Java\jre7
This should work in windows 64 environment as it worked for me in win7 64bit version.
I have changed the java installation path from c:\Program Files (x86)\java to another folder like c:\java\jdk1.7 and updated the %Java_HOME% and path values accordingly,it worked.
example
%JAVA_HOME% = C:\java\JDK1.7
path-C:\java\JDK1.7\bin;
I had the same problem in Eclipse and I fixed it by changing the JRE from 64 bit to 32 bit:
Window > Preferences > Java > Installed JREs > Add... > Next > Directory > select "C:\Program Files (x86)\Java\jre1.8.0_65" instead of "C:\Program Files\Java\jre1.8.0_60"
I had a similar problem (trying to start a Jenkins slave agent on Windows) on Windows 2008R2, Java 1.7.0_15
I had two situations that contributed to the problem and that changing both of them fixed it:
1) Installing Java in a unix-compatible path (changing from c:\Program Files\... to c:\Software\...); I don't think this directly affected the problem described in this thread, but noting the change;
2) Running Java not through a shortcut. It originally failed with a shortcut, but re-running from the direct executable (C:\Software\Java...\bin\java) worked.
Reinstalling java didn't help me. But the trick to put the JAVA_HOME variable at the beginning of the env-vars. The problem occoured after an upgrade from jdk1.7.0_11 to jdk1.7.0_13
I had this problem after updating your java. The best way to solve this problem is just go to your c:/ProgramFiles/Java folder. There you will find two jre folders one is as jre.your version and other with exactly like jdk folder. Try to remove jre.1.your version folder. There you go your problem is solved. Hope this might help. It's worked for me.
Typically it because of upgrading JRE.
It changes symlinks into C:\ProgramData\Oracle\Java\javapath\
Intall JDK - it will fix this.
Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'
Looking # it the issue of post install script is there and getting propagated since I am using update jdk8 1.8.0_191 since issue occurred with me after installing update of java and which was happened automatically.
Error: could not open `C:\Program Files\Java\jre1.8.0_191\lib\amd64\jvm.cfg'
This will be never ending in this case and need to do workaround like changing path's manually.
Delete the jars under system32 for windows.
Delete the jars under C:\Program Files\Common Files\Oracle
Edit the environment variable set JAVA_HOME and SET PATH to bin
I have solved this issue by deleting the Oracle folder from Program Data. And also delete the oracle java path associated with that folder from environment variables.
I kept variable name as "Path" but it did not work after changing it to "PATH"
started working for me.
variable name: PATH
variable value: C:\Program Files\Java\jdk-19\bin
this will work.
It wasn't in the path. Finally fixed by uninstalling java, removing all references to it from the registry, and then re-installing. None the wiser, but back working again. Thanks all #Highland Mark- Can you tell me the process to removing references from registry. I tried all possible way people mentioned here, nothing worked.
If you have downloaded several Jdks you have to delete all except of the JDK you want to use!

How can I set the PATH variable for javac so I can manually compile my .java works?

Here's the address on my drive:
C:\Program Files\Java\jdk1.6.0_18\bin
How would I go about setting the path variable so I can go in command window (windowskey+r "cmd") and be able to type things like:
javac TestApp.java
I'm using Windows 7 Professional.
That would be:
set "PATH=%PATH%;C:\Program Files\Java\jdk1.6.0_18\bin"
You can also append ;C:\Program Files\Java\jdk1.6.0_18\bin to the PATH in the user environment dialog. That would allow you to use javac and other java tools directly form any cmd shell without setting the path first. The user environment dialog used to be somewhere in the system properties in XP, I have no idea where it is in Windows 7.
Typing the SET PATH command into the command shell every time you fire it up could get old for you pretty fast. Three alternatives:
Run javac from a batch (.CMD) file. Then you can just put the SET PATH into that file before your javac execution. Or you could do without the SET PATH if you simply code the explicit path to javac.exe
Set your enhanced, improved PATH in the "environment variables" configuration of your system.
In the long run you'll want to automate your Java compiling with Ant. But that will require yet another extension to PATH first, which brings us back to (1) and (2).
Step 1: Set the PATH variable JAVA_HOME to the path of the JDK present on the system.
Step 2: in the Path variable add the path of the C:\Program Files\Java\jdk(version)\bin
This should solve the problem.
Happy coding!!
Type cmd in program start
Copy and Paste following on dos prompt
set PATH="%PATH%;C:\Program Files\Java\jdk1.6.0_18\bin"
Follow the steps given here
http://www.javaandme.com/
after setting variable, just navigate to your java file directory in your cmd and type
javac "xyx.java"
or if you don't navigate to the directory, then simply specify the full path of java file
javac "/xyz.java"
First thing I wann ans to this imp question: "Why we require PATH To be set?"
Answer : You need to set PATH to compile Java source code, create JAVA CLASS FILES and allow Operating System to load classes at runtime.
Now you will understand why after setting "javac" you can manually compile by just saying
"Class_name.java"
Modify the PATH of Windows Environmental Variable by appending the location till bin directory where all exe file(for eg. java,javac) are present.
Example : ;C:\Program Files\Java\jre7\bin.
only this will work:
path=%set path%;C:\Program Files\Java\jdk1.7.0_04\bin
You don't need to do any complex command-line stuff or edit any system code.
You simply have to open Computer, showing all of your disks and open properties.
From there, go to Advanced System Settings and click Environment Variables.
Scroll down in the lower list box and edit Path.
Do not erase anything already there. Put a ; after it and then type in your path. To test, open command prompt and do "javac", it should list around 20 programs.
You would be finished at that point.
By the way, the command to compile is javac -g not just javac.
Happy coding!
Trying this out on Windows 10, none of the command-line instructions worked.
Right clicking on "Computer" then open Properties etc. as the post by Galen Nare above already explains, leads you to a window where you need to click on "new" and then paste the path (as said: without deleting anything else). Afterwards you can check by typing java -version in the command-line window, which should display your current java version, if everything worked out right.

Categories