Add JAVA_HOME and JAVA_HOME/bin in your environment variable - rhomobile

I have extracted this from the book called
Rhomobile Beginner's Guide
Abhishek Nalwaya
Published Jul 2011
on page 18 it says:
Add JAVA_HOME and JAVA_HOME/bin in your environment variable, PATH.
To add this in PATH click on Environment Variables in Advanced Tab of System Property.
Select Path in System variables and add JAVA_HOME and JAVA_HOME/bin to textbox and click Ok.
What should be the value?

It will let you and other applications run Java tools without having to type the whole path.
I disagree about adding JAVA_HOME; I only have JAVA_HOME/bin in my PATH.
Tomcat requires that JAVA_HOME be set properly in order to operate; so do some other Java EE app servers. (I believe WebLogic needs it.)

The value should be the install directory for your JRE or JDK,
Browse your 'program files' folder for a java folder, should look something like:
C:\Progra~1\Java\jdk1.6.xx\
There will be a directory called bin inside it.

Related

JAVA_HOME or PATH or BOTH?

I was watching the Android development video and they asked us to install JDK and create JAVA_HOME environment variable.
I already have MyEclipse installed and I previously had setup the PATH variable(giving it the directory of JDK), do I still need a JAVA_HOME variable ??? If yes then why ???
Yes, you do need.
PATH is usually used to lookup the executables so that you haven't to specify the whole path to execute. JAVA_HOME may be used by the scripts or IDEs to lookup libraries. You can specify JAVA_HOME and build path variable basing on it. E.g (depending on OS)
PATH=$PATH;$JAVA_HOME/bin
Short answer, YES, you do need to set JAVA_HOME.
You can read here the difference between each one of them, but I'm pasting the explanations below as well:
JAVA_HOME and JRE_HOME are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME.
CLASSPATH is an environment variable which contains a list of directories and / or JAR files, which Java will look through when it searches for Java classes to load. You do not normally need to set the CLASSPATH environment variable. Instead of using this environment variable, you can use the -cp or -classpath option on the command line when using the javac and java commands.
PATH is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. You should add the bin subdirectory of your JDK installation directory to the PATH, so that you can use the javac and java commands and other JDK tools in a command prompt window. The JDK installation instructions explain how to set PATH.
If the application you are using is looking for a specific dataset in the JAVA_HOME environment variable and it isn't there, it is not going to be happy.
Other applications might look for the JDK path in the PATH environment variable, but just because you have it there doesn't mean it will work for other applications that need it in a separate variable.

Java windows command

I am trying to compile some java code on Windows 7 pc, I have installed java JDK and I am trying to use the javac command in cmd but I get output saying that
'javac' is not recognized as an internal or external command,
operable program or batch file.
What do I have to do to enable compiler in cmd or is it possible to do in Windows?
1)Go to properties by right click on icon Computer , then navigate to Advanced System Settings.
2)Click Environment Variables.
3)Click on New , set Variable name as path and Variable path as the path of java jdk installation directory which could be something like this -
C:\Program Files\Java\jdk1.6.0_23\bin;
where C:** is the drive where JDK is installed and **Program Files\java is the directory where it resides.
look out for semi-colon(;) at the last.
4)Click ok
5)Restart cmd and run javac , it should work now.
Look for Screenshots here for more help.
Regards
Anshul
you have to set a new system variable for your JAVA_HOME in windows.
See here for further information.
Add the path to bin folder of JDK in your PATH variable. For instructions to set PATH variable follow this tutorial.
Your java directory is not on the path. Here are some helpful screenshots to show how to set it up:
http://vietpad.sourceforge.net/javaonwindows.html

Error while installing jruby on windows 7

I am trying to install JRuby in my system, I follow the following steps:
Download a copy of the latest JRuby from the JRuby download page.
Unzip the file with your achive program. If you don't have one that works, download 7-Zip.
Copy the JRuby folder called jruby-1.7.2 directly to "C:/"
Set environment variables on your system. Right click "My Computer" go to "Advanced" then "Environmental Variables". Create these: JRUBY_HOME = C:/jruby-1.7.2
Next you'll have to edit the PATH variable. Add ;C:\jruby-1.1.5\bin; to the end of that variable.
And then I am running the command:
C:\Users\sitanshu\rubyApp\jruby-1.7.2>jruby -v
then it shows the following error:
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) Client VM 1.7.0-ea-b19 [Windows Vista-x86]
NameError: uninitialized constant Java::JavaLang::ProcessBuilder::Redirect
const_missing at org/jruby/RubyModule.java:2677
ProcessManager at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:12
JRuby at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:6
(root) at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:3
load at org/jruby/RubyKernel.java:1046
(root) at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel.rb:1
So where am I going wrong and what is the solution for that?
I would test that java is updated and working
java -version
Under your environment variables, make sure you have a JAVA_HOME variable pointing to your JRE root folder, like this:
C:\Program Files\Java\jre7\
Make sure your Java JRE bin folder is also part of your PATH variable:
;C:\Program Files\Java\jre7\bin\
Additionally, when you are adding jruby to your PATH variable, make sure you are referencing the correct folder location. In the example you have given, you are installing jruby to C:\jruby-1.7.2, but then you are actually referring to this different folder C:\jruby-1.1.5 in your PATH configuration.
Also, when you are defining your JRUBY_HOME variable, make sure you are using backslash \ characters. In your example above you used a forward slash / character. Remember, that windows uses backslashes between folders.
Finally, after you've made all your environment variable changes, remember to open a new command window for your changes to take effect.

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.

Old solution not working for missing Tools.jar while building Portico on Red hat Linux using apache ant

I have already done my homework before posting this question. I am trying to build Portico-1.0.2 on Red-Hat Linux 64 bit machine using apache ant. Initially I was setting JAVA_HOME path to jre-1.6.0_31/bin folder but it threw an error that : Unable to locate tools.jar. Expected to find it in jre1.6.0_31/lib/tools.jar.
Then after exploring stackoverflow I found few posts explaining to install jdk and set its folder as the JAVA_HOME path. So I have installed Jdk-1.6.0 in Redhat Linux and after installing jdk I located tools.jar file in it's lib folder. Now when I set the JAVA_HOME path to : /usr/lib/jvm/jre-1.6.0-openjdk.x86_64, it throws an error : portico-1.0.2/codebase/build.xml:55: The JAVA_HOME environment variable must be set
But I have set the JAVA_HOME in .bashrc file as follows :
JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
PATH=$JAVA_HOME:$PATH
I am not sure what to do. Any advice on how to solve this problem.
Confusingly the JDK also contains a JRE, the latter you've set as JAVA_HOME thereby repeating your problem...
The Red hat docs describe how to set the JAVA_HOME
hi open the bashrc file in the root directory and add the path to your jdk and you will be good to go..
eg
export JAVA_HOME=/usr/java/jdk1.6.0_19
export PATH=$PATH:$JAVA_HOME/bin

Resources