can't set path for javac - path

I've put in an embarrassing amount of time reading threads here and elsewhere, I cannot compile HelloWorldApp.java
Using Windows 7
the location of the script is C:\Users\Phil\Desktop
the location of javac is C:\Program Files\Java\jdk1.8.0_77\bin
In Environment Variables, in both User and System Variables, I have clicked NEW, and given the "Variable Name" as javac and "Variable Value" as `
C:\Program Files\Java\jdk1.8.0_77\bin;
`
I have tried to make this work based on the 2 different ways here (to no avail): https://docs.oracle.com/javase/tutorial/getStarted/problems/
I am failing to set a path, or tell computer where to find it from within cmd. What am I doing wrong?

just you have to do set temporary path set path=C:\Program Files\Java\jdk1.7.0_45;
or
change your Environment variable path
to
variable name=%path%
variable value:\Program Files\Java\jdk1.7.0_45;
then open cmd and run javac command to check

Okay, so I have solved my problem:
In Environment Variables, the "Variable Name" must be: PATH
The Variable value is: C:\Program Files\Java\jdk1.8.0_77\bin
Now It works!

Related

Need Help understanding how PATH works with Windows 7

I am trying to add to the PATH via the Environment Variable settings windows for python.exe.
I have read the instructions using SetX from the March 3, 2012 discussion about this issue and am worried I will make a mess of my machine, so want to stick with the GUI process.
The directory path is C:\Users\Paul\AppData\Local\Programs\Python\Python37\python.exe.
That is a copy from the addition I made in the System Variables section of the Environment Variables window.
I have labelled the Variable Name as "Python", no quotation marks.
I have checked the path, and it looks good to me, and have rebooted the computer. But I still get the
'python.exe' is not recognized as an internal or external command, operable program or batch file.' error in every directory expect if I am specifically in the Python37 directory.
Any idea what I am doing wrong?
The path environment variable contains one or more paths, separated by semicolons. When you try to execute a command in cmd.exe it checks each path listed in the path variable in order of first to last until it finds the executable or runs out of paths to check.
You can experiment without making permanent changes to your system first. Run cmd.exe and type
set path=%path%;C:\Users\Paul\AppData\Local\Programs\Python\Python37
Running python.exe should now work in any directory in this cmd.exe window.
Unlike other environment variables, path is special and is a merged value from the system and user variables. Since you installed python just for yourself you might as well just use a user variable.
In the system properties where you edit environment variables, if there is no path user variable, create one and set it to C:\Users\Paul\AppData\Local\Programs\Python\Python37 or if it already exists, append ;C:\Users\Paul\AppData\Local\Programs\Python\Python37.
In newer versions of Windows 10 the UI is different and you don't have to add the semicolon because it lets you edit them as separate entries.

ant error "The syntax of the command is incorrect." on running ant.bat

I tried various ant versions and also tried running the command directly from ant_home/bin directory, but no luck only below error:
ant error "The syntax of the command is incorrect." on running ant.bat
kindly help on this, I am not finding anything helpful anywhere on the web.
Thanks
Luckily I got the problem root cause and solved it :)
The reason was my java_home was ending with a " character in environment variable, after removing the " from java_home path, ant started working as expected.
to investigate the aforesaid I just opened the ant.bat in notepad and in the first line I changed echo "off" to echo "on", by doing that, when I hit ant.bat in the command prompt it logged the exact line of ant.build file where the aforesaid error was being thrown.
I have JAVA_HOME set with proper path but it was pointing to JDK 1.8. I need to change it to point to JDK 1.6 in order to resolve the issue.
The ANT_HOME and JAVA_HOME environment variables are configured in some user machines with "" surrounding the paths, to overcome the spaces in the folder paths.
Having the folder paths with "" around them could be the reason for the message. Either the quotes are to removed or the multiple paths are to separated by ";"
Ref : https://www.mail-archive.com/dev#ant.apache.org/msg37855.html

Javac is not being recognized even after setting the class path variable

My problem is that I have set the bin path in Class path variables. After that
Command Prompt is recognizing "java" command but "javac" program is still not being recognized.
Make sure you are pointing to the "bin" directory of the jdk and NOT jre. Also, as Juned answered, you need to open a new command line after you update the environment variable in "PATH"
Assuming you have set the jdk/bin folder path to your system PATH variable.
Just make sure you re-open the command line because an open command line does refresh itself with the new environment params.
After adding jdk/bin to your PATH, simply launch a new command prompt and type javac, java magic should start happening.
Adding C:\Program Files\Java\jdk1.8.0_121\bin to Path environmental variable should be done. But you shouldn't insert any space between the previous ; and the path of bin folder:
Path: c:\some name\.....\; C:\Program Files\Java\jdk1.8.0_121\bin ==>WRONG
Path: c:\some name\.....\;C:\Program Files\Java\jdk1.8.0_121\bin ==>OK

MacBook OS X 10.8.2 ant unable to find custom environment variables

When I run targets on ant it says it is unable to locate the variable I passed to it.
Config for environment variables :
in build.xml
<property environment="Env"/>
but I am unable to find the parameter defined parameter with
${Env.CATALINA_HOME}
where in the .bash_profile
export CATALINA_HOME=/Users/olgunkaya/development/apache-tomcat-7.0.34
and export PATH=${PATH}:$CATALINA_HOME
What can I do to achive this ?
Before you run ant, check to see if CATALINA_HOME is actually defined as an environment variable. I bet you'll find it isn't. Ant doesn't read your .profile or .bash_profile before starting, so if it's not already defined in your environment, Ant won't see it.
As you've seen opening a terminal window on a Mac doesn't necessarily guarantee that the .bash_profile file is executed. Try setting up these environment variables in .bashrc file instead.
Or, you can force .bash_profile to run by setting it as the Startup file in Terminal. Select File->Preferences from the menu, go to the Shell tab, select your default shell, and then click the Run Command checkbox and put .bash_profile in there. That will guarantee that .bash_profile is executed with each new terminal window.
I had a similar problem when referencing a custom variable, which was definitely defined in the shell spawning ant.
The solution was to EXPORT the variable when defined (in ~/.profile), so the shell would pass it to its children.

Setting up the path for Maven 3.0.4, win7

I have been trying to install Maven v 3.0.4 on my machine win 7 for the first time.I have a problem setting the path environment System variable I have the following 4 entries :
PATH
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_04;C:\Program Files\apache-maven-3.0.4\bin;M2_HOME;%M2%
M2_HOME
C:\Program Files\apache-maven-3.0.4\bin
M2
%M2_HOME%\bin
JAVA_HOME
C:\Program Files\Java\jdk1.7.0_04\bin
when I do mvn --version
I get the error:
JAVA_HOME not found in your environment, please set the JAVA_HOME variable in your environment to match the location of your java installation
The java -version displays the java version fine,
what am I doing so horribly wrong? Is the PATH ok?
Help appreciated, thanks.
It is only necessary to set the path to the Maven binary and to the JDK correctly:
set PATH %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_04\bin;C:\Program Files\apache-maven-3.0.4\bin
Furthermore you need to set the JAVA_HOME correctly which is done under windows like this:
SET JAVA_HOME=C:\Program Files\Java\jdk1.7.0_04
Be aware of setting JAVA_HOME to the root of the installed JDK and not to bin folder it.
The settings of M2 and M2_HOME is not necessary.
from command prompt run the following
set M2_HOME= C:\Program Files\apache-maven-3.0.4
set PATH=%PATH%;%M2_HOME%\bin
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_04
set PATH=%PATH%;%JAVA_HOME%\bin
cmd.exe
mvn -version
The environmental variables should point to the installation directory of each program respectively, and their corresponding bin folders should be added to the PATH:
Make sure that your JAVA_HOME points to the C:\Program Files\Java\jdk1.7.0_04 (or whatever directory you have installed your JDK to).
Add the %JAVA_HOME%\bin folder to your PATH (e.g. by replacing the part with C:\Program Files\Java\jdk1.7.0_04). Make sure that you use ; to separate different path components.
Likewise, the M2_HOME variable should be assigned Maven's installation directory, e.g. C:\Program Files\apache-maven-3.0.4 and you should add %M2_HOME%\binto the PATH (the part with C:\Program Files\apache-maven-3.0.4\bin;M2_HOME;%M2% can be removed.
The advantage of adding the environmental variables %JAVA_HOME%\bin and %M2_HOME%\bin on the path rather than the fully qualified path is that it will be easy to update Java and Maven (or to have several versions installed in parallell). All you need to do is to update the environmental variable, and the PATH variable will fallow automatically.
I ran into the same issue as the original poster. I checked, double checked, and triple checked everything to conform to what everyone has (correctly) indicated the setup needs to be. I still got the same error. In the end, I ran SET JAVA_HOME=C:\Program Files\Java\jdk1.7.0_45 from the command line and then ran the mvn command and viola.
So, for what ever reason, pss's suggestion did the trick. Obviously, this doesn't really change what everyone else said, because that's exactly what my environment variables look like...just had to hit the JAVA_HOME from the command line.
Oddness.
I followed all the steps but it was not working for me. But as soon i have set the JAVA_HOME Path, in Command prompt just type:
C:>SET JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_91
It is working fine in fraction of seconds. Thanks Everyone.
I faced the same problem on local installation. I tried out all the suggested methods including the SET method but that didn't work for me. In the end, I had to manually add another environment variable to the system, and then after that
mvn -v
gave the appropriate response:
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T04:57:37-07:00)
Maven home: C:\Program Files (x86)\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin\..
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8", version: "6.2", arch: "amd64", family: "dos"
If, like me, you are running mvn -version from the command prompt, and then adding any missing environment variables from the GUI, it is possible that you just have to reload the command prompt after adding the environment variables.
Just exit and run cmd.exe
You need to make a variable of name JAVA_HOME in your Environment and set its value as path to jdk.
Right click on My Computer/ This PC -> Properties
Choose Advance system settings
Open Environment variables
Under System variables click on New... button and give the name
as JAVA_HOME and value as c:/path/to/jdk
Version that I always use. Double click and you get the maven up and running
#echo off
title Maven 3.0.5
set JAVA_HOME=C:\Users\hutingung\Development\jdk\jdk1.6.0_33
set MAVEN_OPTS=-Xmx1024m -Xms512m -XX:MaxPermSize=192m -Dfile.encoding=utf-8
set MAVEN_HOME=C:\Users\hutingung\Development\tools\apache-maven-3.0.5\bin
set PATH=%MAVEN_HOME%;%JAVA_HOME%\bin;%PATH%
#cmd /k
Yes, Appending that path C:\programfiles\maven\bin to path variable in system variables is enough, it will work. No need to add user variables.

Resources