i am relatively new to java. when i installed jdk and jre on my laptop it asked me to set a system variable with the name path and a value of its home directory. next i installed tomcat server and that too asked me to set CATALINA_HOME,JAVA_HOME and path as its home directory.now after mysql installation it also said a variable of path with its home directory value.will it not effect the old s/w if i change path variable to new software variable address?? or should i create new paths for each software??
CATALINA_HOME and JAVA_HOME are separate variables and should be set separately.
As for the PATH, this is one variable and should contain all necessary values separated by the ; character.
Related
At my work I have user access with no admin privileges. My environment variable points to an old JDK at the current path: C:\ProgramData\Oracle\Java\javapath
From what I read on different posts such as this which states that all user variables override the environment variable except the PATH variable in which it concatenates the environment variable and user variable together. I have followed many different tutorials and currently have my variables set up like this in my user PATH variable.
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_79
JRE_HOME = C:\Users\316830207\jre7
PATH = C:\Users\316830207\AppData\Roaming\npm;C:\Users\316830207\AppData\Roaming\jdk1.7.0_79\bin
TMP = %USERPROFILE%\AppData\Local\Temp
If you notice my PATH variable for the user has npm path as well as jdk. The npm path was added so I could bower from the command line. That works! However the path for the JDK is never used. No matter what when I type java -v I get
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
Since the path variable contacts the only thing I can think of is it skips my JDK path or overwrites. I have tried using command line using setx as I cannot use setx /M as I do not have admin access. I have searched for a few days now and the only conclusion is I am doing this wrong or security from my work is stopping me to overwrite JDKpath.
So my question is am I setting the JDK path incorrectly? Is there a different way I can set it? Why will it only use my environment path and not my user JDK path?
JAVA_HOME contains the installation path of JAVA.
Set environment variable JAVA_HOME to installation path C:\Program Files\java\ jdk-1_7_0_08 using following steps for windows user
1. Right Click on My Computer->Properties-> Advanced->Environment Variables ->User Variables -> New
2. Set JAVA_HOME to value C:\Program Files\java\ jdk-1_7_0_08
As depicted in above image java home is set and is being echoed but when i check for version it gives me latest version.
Already restarted the command prompt after setting env variable.
OS is Windows 7
Update:
Following is the Path.
..ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;;%JAVA_HOME%/bin;
I had the same trouble and I solved it with the following steps:
You need the correct environment variables.
To be exactly correct, you only need to set the Path variable.
You need to find where you add %JAVA_HOME%\bin to the path.
Put it at first place in the Path variable:
%JAVA_HOME%\bin;...
where ... represents all other values of Path.
I assume that JAVA_HOME is defined as a variable and had the correct value.
After this reopen console and check:
java -version
JAVA_HOME is environment variable that various application reads in their launcher script
when you invoke java it looks up for all paths specified in your env variable named PATH and wherever the first match is it gets picked up
so if you like command prompt to refer to jdk 6's Java append the path to PATH
You need to add the path to jJAVA_HOME%/bin directory in the path variable too. java command is located in %JAVA_HOME%/bin
Check your PATH environment variable also. Your system is referring to latest Java installation through PATH variable.
I think in your path variable you have hardcoded the path to bin folder. it should always be %JAVA_HOME%/bin.
So that it can pick path from JAVA_HOME variable and you don't need to change both the variables every time.
When we set the environment path, can't it work correctly for Java, Eclipse and Android Studio?
How to set it correctly?
When I set it temporarily by using the command prompt, set path is not working correctly.
So I tried to set it permanently by using the environment variable Path, but it's not possible.
How can I set it properly?
Please give me a detailed explanation
Apart from setting the JAVA_HOME system variable you need to set the Path variable as well because the Path is the system variable that your Operating system uses to locate the needed executable from the terminal window.
So for setting the Path Variable proceed as follows:
Right click on the My Computer icon --> Properties -->Advanced system settings --> Environment Variables
Now under System variable scroll to the Path variable
Select Path variable and click on edit button
Now add %JAVA_HOME%\bin in the end of Variable values, separating this value form the existing one in the list with a ;
eg xxxxx;%JAVA_HOME%\bin;
Note that before following the above steps also check if your JAVA_HOME variable is properly set. For doing this go to command prompt and type echo %JAVA_HOME%. If it is properly set then it will give you the path of your jdk.
NOTE: Sometimes it happens that both the Path and JAVA_HOME variables are set properly but still things are not working.To avoid this run the command prompt as administrator.
Android Studio uses JAVA_HOME variable , not Path variable. So You should set up JAVA_HOME Variable.
Right-click the My Computer icon on
your desktop and select Properties
Click the Advanced tab. 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.
Note:Normally
installation path is like "C:\Program Files\Java\jdk1.7.0"
OK, what am I doing wrong, this is driving me nuts.
I am trying to install the latest JDK (1.6.0_23). So, I downloaded it from Oracle's awful site and then ran the installation. I installed it to C:\Java\jdk1.6.0_23
Then, I created a JAVA_HOME User Variable that pointed to C:\Java\jdk1.6.0_23. I then added a piece to the end of my Path environment variable that says %JAVA_HOME%\bin.
However, when I try to simply open a command prompt and run simple java commands, I am told it is not a recognizable command. I have to manually cd into the that bin directory to do anything.
Do I also need a Classpath variable that points to the JRE? I noticed there was a Classpath variable there previously that pointed to jre/lib/QTJava.zip, but I deleted it.
If you have the JDK installed and a JAVA_HOME variable setup, do I still need the JRE in the classpath? I am running Windows 7 and do all of my development in Eclipse.
Maybe the problem is because you set JAVA_HOME as a user variable, but trying to reference it from the PATH which is a system variable (or is it?). You cannot do this, because system variables are evaluated before user variables.
There are two possible solutions:
1. Set JAVA_HOME as a system variable instead
2. Create a new user variable PATH and set %JAVA_HOME%\bin there. The user PATH and the system PATH variables will be concatenated at runtime automatically.
From http://social.answers.microsoft.com/Forums/en-US/vistainstall/thread/48b23109-9fbc-47c5-a5d1-465773f94704
(at the end)
1) Enable 'delayed variable expansion'
in the registry (see
http://batcheero.blogspot.com/2007/06/how-to-enabledelayedexpansion.html)
2) Change the '%' signs around var2 to
'!', e.g. "%var2%" becomes "!var2!"
I've done some limited testing on
Windows 7 and this appears to fix the
problem.
Maybe try that, see if it fixes it (I don't have windows here to try)
Do I also need a CLASSPATH variable that points to the JRE?
Strictly speaking, no. The CLASSPATH variable may be used if you try to run a java class and you don't use the -cp or -jar options.
The CLASSPATH variable doesn't need to point to the JRE. The java.exe command etc all know where to find the JRE's runtime classes. (And they don't look on the CLASSPATH for them anyway.)
For the PATH problem, try running:
C:\Java\jdk1.6.0_23\bin\java.exe -version
If that doesn't work then there's a problem with your actual installation. If it does work, try looking at what JAVA_HOME and PATH are set to in the environment variables of the command shell.
I cannot run the java keyword from the console. What settings do I have to change on XP to get this working.
Thanks in advance.
Install the JVM (or JDK)
Set the JAVA_HOME environment variable to the installation folder
Add the executables location into the PATH environment variable (referencing JAVA_HOME)
Optionally set a CLASSPATH environment variable to have a default classpath
When you install the Sun JRE using its installer, there should be a java.exe file written to %windir%\SYSTEM32. Since this directory is on the PATH, it should be available on the command line.
If you installed Java via some other mechanism, you will have to locate the JRE's bin directory and configure PATH yourself.
right click on computer -> property -> advanced -> environment variable
then choose where save the path:
- in user variable (the path is associated to the user, every other user cannot directly run java, without setting it up).
- in system variable (every user can run java by console without specify the entire path).
choose row with path, double click -> at the end on the line add an ; and then specify the java installation path plus bin...
Exmple:
I installed java in C:\Programs\Java
so I have to put in path C:\Programs\Java\bin\
in Path I had:
%CommonProgramFiles%\Microsoft Shared\Windows Live;%SystemRoot%\system32
after modification I'll have
%CommonProgramFiles%\Microsoft Shared\Windows Live;%SystemRoot%\system32;C:\Programs\Java\bin\