I need to install an MQ server (Apache ActiveMQ Artemis 2.27.x) on Linux for our team. I just read some documentation and articles.
Since our Linux server is messy, there may be many JDKs, and the environment variables are not reliable, so I want to specify the JDK path for Artemis (like, put JDK in the Artemis directory), but I haven't searched for a satisfactory solution.
I first did a test installation on my Windows machine. I tried modifying artemis.cmd (setting the JAVA_HOME environment variable) and it worked, but I don't think it's a good idea as doing so could be potentially dangerous.
Is there an elegant way to configure JDK for Artemis? Like modifying some Artemis configuration files.
When you run the artemis create command to create an instance of the broker you can either set JAVA_HOME in your environment (e.g. export JAVA_HOME=/path/to/jdk) or you can modify the artemis script directly.
Once the instance is created then the proper place to configure JAVA_HOME is in etc/artemis.profile. Just add a line like this:
JAVA_HOME=/path/to/jdk
Related
Is it possible to configure JRE in AIX without using installp.
By simply downloading the archive file which contains a complete java directory (like in windows).
And later on, setting environment variables like JAVA_HOME in os (if required).
If yes then please provide me link where I get that archive of jre.
If no then please suggest me to install jre in AIX without overwriting the previous version of java (which is already install in machine)
and environment variables related to installed java.
The only provider of JDK/JRE for AIX is IBM. And as far as I know the only format they provide is in package (to be installed with installp). And AFAIK you can't install it on different place. Moreover this installation will update probably your current installation. And of course will keep all your settings
I've been setting Windows environment variables (like JAVA_HOME) every time I installed a Java update. (As per Environment variables for java installation).
However, I've recently noticed that Java updates add C:\ProgramData\Oracle\Java\javapath; to the System Path (not the User Path). I removed JAVA_HOME, etc from my User Path, and java -version seems to work from any directory.
Does that mean that it is not necessary to do that simple but annoying task with each Java update?
That depends on what you are trying to do.
Generally, you don't need JAVA_HOME to run a Java app. Adding the location of the Java binaries to the PATH is sufficient for Windows to find and execute them.
However, e.g. a lot of application servers like Tomcat and build tools like Gradle will use JAVA_HOME to determine the location of your Java installation.
Java itself does not use JAVA_HOME. Some third-party things like IDEs and Tomcat do. I've never set it as an environment variable in 20 years.
Personally, I don't even have JAVA_HOME set and I've been developing at this company for 6 years now (and other companies for 10+ years). To me, it tends to get in the way. The last install sets the windows path which generally isn't what my IDE's, Tomcat, JBoss or SOAP-UI support so I just edit all their startup files to choose/set the JAVA_HOME they work with.
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk-i386/jre"
Erm.. But it is pointing to a JDK, open-JDK here. Am I missing out on something here?
Ignore all solutions which suggest adding/setting a JAVA_HOME directory, they are wrong. If you have one set in your .profile etc, remove it.
Ubuntu (and a number of other distros, esp. debian based ones) use an 'alternatives' mechanism to provide a higher level of abstraction to handle things like multiple versions of the same software or multiple sotware packages which provide the same functionality, such as web browsers.
Ubuntu does not require a JAVA_HOME setting, provided you let the OS and it's packaging system manage your environment. If your manually installing things, your then on your own and need to work it out.
I suspect that originally, you only had the JRE installed, you then attempted to fix your problem by adding a JAVA_HOME setting and then later installed the required JDK. If this is the case, remove your JAVA_HOME setting and then use the update-alternatives command to make sure the correct java environment has been setup (see the man page for update-alternatives for details - its very easy).
The advice on using lein is IMO spot on and I would also recommend using the script rather than the packaged version. I would also recommend going witht he 2.0 preview version. It is quite stable and a better place to start than the older 1.x versions.
You could just install leiningen (which is packaged with Ubuntu). This will give you a nice project tool for working with Clojure. It bootstraps and pulls clojure in for you on a per package basis, which will also mean that you have more than one version.
Remove the jre part in the path. That should do the trick.
It would become
"/usr/lib/jvm/java-6-openjdk-i386"
Also as Brian suggested try
sudo apt-get install openjdk-7-jdk
Most unix commands whose operation changes based on values of environment variables have a section "ENVIRONMENT VARIABLES" in their man page. No such luck for the java binary (Sun/Oracle Java 6), though I'm fairly certain that things like CLASSPATH and perhaps JVM_OPTS have an effect.
Can anyone point me to a list of environment variables that affect the 'java' binary?
I don't think there are that many, but it will depend on what implementation (oracle vs ibm).
IBM's JDK has a list here: http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/topic/com.ibm.java.doc.diagnostics.50/diag/appendixes/env_var/env_jvm.html
The oracle JDK has, at the very least, CLASSPATH, JAVA_HOME and JRE_HOME. Although in the man page for "java", the only environment variable it mentions is CLASSPATH.
Other tools like ant or tomcat may look for JVM_OPTS, and JBoss uses JAVA_OPTS.
Setting JAVA_HOME to the installation directory and adding $JAVA_HOME/bin to the PATH sould be enough, if you don't have to configure build systems like maven or ant.
CLASSPATH is required on most start scripts to contain the location of supporting libraries (.jar) or third-party stuff.
JAVA_OPTS usualy contains parameters for setting heap-space, debug agent and things like that.
AFAIK java itself does not depend on environment settings, rather start scripts, init services and anything build around.
Thus you won't find a single list of all environment variables related to java (software-products).
There is also _JAVA_OPTIONS, mentioned here, which works for all JVM invocations, including applets and Webstart.
Incomplete answer to my own question:
Oracle has a list for Java 8 of env variables to include when reporting a bug. Not really documentation, and no guarantee it's complete, but it is highly suggestive:
JAVA_HOME
JRE_HOME
JAVA_TOOL_OPTIONS
_JAVA_OPTIONS
CLASSPATH
JAVA_COMPILER
There is specific documentation on JAVA_HOME and JAVA_TOOL_OPTIONS
I have a couple of applications running on Java 1.4.2_12 and now need to add an new application that uses Java 1.5. Can I have both java versions on a windows server?
Yes. You just need to make sure that each has the correct version of Java/the JRE on its CLASSPATH, PATH and JAVA_HOME environment variables.
Yes: actually JDK or JRE can be just "copied" wherever you want, not "installed" (avoiding putting anything in c:\Windows\System32)
I would also recommend not using global environment variables.
That way, your applications depend entirely on local settings (local to the application), and not on external Java installation side-effects
Are you sure you have to have the Java 1.4.2_12 apps run using that specific Java VM? Most apps should run fine on the newer VMs, so you might be able to simply have them all use 1.5.
If you do need to use the specific VM versions then you can do what other posters have suggested.
YES. See above. Of course, running two VMs (of any version) takes twice the RAM.
I could suggest you to use Java WebStart, which allow you specific the target J2SE version in the JNLP file. Or; always execute the right version "java.exe" under "Program Files" by absolute path.
You don't have to set CLASSPATH for JRE (and should not in modern JRE). JRE have it own bootclasspath automatically. CLASSPATH is used by your application.
Usually you won't have to set the JAVA_HOME unless your appliaction is looking for resources from JDK\lib\ (e.g. tools.jar which contains compiler)
But I am not sure what's your problem.
Are you running client application(swing)? Two Java processes to provide services? or two application sharing same Java application server?