Setting $PATH and $JAVA_HOME from IzPack install.xml - path

I see that $JAVA_HOME is a built-in variable in IzPack. Can I assign to it in a pre-install script and have the installer use that? Currently I am stuck on a machine that defaults to an open-source JRE that runs horribly and I need to reassign it to the Sun JRE so that the installer will run properly.
In the pre-install script, can I append to the $PATH with:
${ENV[PATH]} = ${ENV[PATH]}:/usr/local/java/bin
Let me know what I can do, I cannot get access to write to the .cshrc or .cshrc.login and I cannot tell my users to set the environment variables themselves.

The answer to this for me was that I had to write a python script that set the environment variables and then called a subprocess to launch the installer. This is far from ideal, but it seems like if your machine is stuck by default with an open source JRE, then you can't fix that any other way.

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.

Scons doesn't use my environment variables such as PATH and LD_LIBRARY_PATH

I have a little problem.
I source a script which changes my RedHat environment (PATH, LD_LIBRARY_PATH, etc.i).
When I launch my install with scons, it charges the default Environment from my machine, but not the current that I loaded...
I tried several attempts, but it was not conclusive. Most of the answer on the net are relative to a change on one variable which have to be set in the SConstruct.
How can I tell scons to charge the current Environment, but not the default ?
Thanks in advance !
The SCons way would be to set these environment variables in your SConstruct/SConscripts so that every user would end up with a reproducible build environment.
Take a read of the FAQ for this: http://scons.org/faq.html#Why_doesn.27t_SCons_find_my_compiler.2BAC8-linker.2BAC8-etc..3F_I_can_execute_it_just_fine_from_the_command_line.
SCons does not automatically propagate the external environment used to execute 'scons' to the commands used to build target files. This is so that builds will be guaranteed repeatable regardless of the environment variables set at the time scons is invoked. This also means that if the compiler or other commands that you want to use to build your target files are not in standard system locations, SCons will not find them unless you explicitly set the PATH to include those locations.
Already found the solution after some more search : env = Environment(ENV = os.environ)

Jenkins service start error on red hat linux

The jenkins service does not start when ever i run jenkins service start . It says
Starting Jenkins bash: /usr/bin/java: No such file or directory
[FAILED]
I have java installed at /usr/lib/jvm/jdk1.7.0_51. The JAVA_HOME variable is also set. Also tried adding this java to /etc/init.d/jenkins file. I need to use the sun jdk, not open jdk.
Tried some of the alternatives from stackoverflow as well but did not work out.
Any suggestions will be of great help.
Thanks,
Bhargav
Thanks Paul. The script inside /etc/sysconfig/jenkins needs to be edited. Else it uses the default java.
JENKINS_JAVA_CMD="path of java installation"
Along with the above script, one can make changes to /etc/init.d/jenkins file if needed to add the path of java installation in your system.
I'd guess that there's a script that has /usr/bin/java hardcoded. When you find the culprit, remove the /usr/bin so that it uses the default. Or you can change it to use the JAVA_HOME path, something like this:
JAVA_EXECUTABLE=$JAVA_HOME/bin/java
$JAVA_EXECUTABLE $JAVA_OPTS etc.. etc..

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.

How to run multiple Groovy/Grails version

As I can run multiple versions of groovy / grails without having to change settings?
GVM (Groovy enVironment Manager) is a great option if you're on Mac, Linux, Solaris, or Windows with Cygwin. GVM supports the installation and management of Groovy, Grails, Griffon, and Gradle.
If Grails is your primary concern and you use a Windows PC in a locked down enterprise where Cygwin isn't an option, look at Gravy or write a batch file as noted above.
It's only about GROOVY_HOME/GRAILS_HOME and PATH environment variables. Start your Grails application from a bat file/shell script which sets these two variables, and you're fine.
Grails distinguishes settings stored in home/.grails for different versions, so versions won't clash there.
If you're on linux or osx, theres a shell script here which might help, and an alternative script is here
I am using 7 grails version on my ubuntu machine . put the code below at the bottom of .bashrc file.
function switchGrails() {
echo “Switching to grails version: $1″
sudo rm /opt/grails
sudo ln -s /opt/$1 /opt/grails
echo “Done!”
}
alias grails225=’switchGrails “grails-2.2.5″‘
alias grails224=’switchGrails “grails-2.2.4″‘
alias grails223=’switchGrails “grails-2.2.3″‘
alias grails233=’switchGrails “grails-2.3.3″‘
alias grails235=’switchGrails “grails-2.3.5″‘
alias grails237=’switchGrails “grails-2.3.7″‘
alias grails2311=’switchGrails “grails-2.3.11″‘
After save and exit . Compile the .bashrc file . Type cd and . .bashrc to compile .bashrc file.
For more reference : https://pkashyap28.wordpress.com/2014/09/11/manage-multiple-grails-application-in-ubuntu/
Add a tip if you are working on Windows: there's a way for quick-changing version of GRAILS. You just need to change GRAILS_HOME & GROOVY_HOME (by script, GUI,...) then CLOSE the cmd window used to run grais-app, then start it again. By this way, the change will be applied and you can avoid restarting.
Following the #tim_yates' answer. (unix based OS).
1- Put all grails versions under opt folder:
/opt/grails-2.3.1
/opt/grails-2.5.3
/opt/grails-3.1.1
2- Download and save grails.sh in somewhere you know. (I put mine at /opt/grails-selector)
Edit your ~/.bash_profile file. The PATH var should point to the folder you put your grails.sh. And set GRAILS_HOME to your default version (in case you are creating a new project, for example, it'll use this default version unless you declare to use another.
export PATH=$PATH:/opt/grails-selector
export GRAILS_HOME=/opt/grails-3.1.9
4- You're good to go. May you need to reopen your terminal or logout-login. When you call grails it will calls the grails.sh and then it looks for the version set in your project. So you it works automatically.

Resources