-
Notifications
You must be signed in to change notification settings - Fork 94
Experimenting with jdk8
If you are on any variant of Debian linux (Mint / Ubuntu etc), there is the convenience of being able to set alternative java using update-alternatives:-
su -c "update-alternatives --config java"
or
sudo update-alternatives --config java
Output
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
1 /opt/jdk1.7.0_51/bin/java 100 manual mode
* 2 /opt/jdk1.8.0/bin/java 100 manual mode
3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
Press enter to keep the current choice[*], or type selection number:
A bit drastic but you can use this script to change the symbolic links
#!/bin/bash
# This script iterates all symlinks in the BIN_DIR directory that have the same JDK path as 'java'
# and replaces every symlink with a new one that has the JDK path set from the first script argument.
#
# Useful if you want to switch symlinks from OpenJDK to any other JDK.
# E.g. ./replace-java-symlinks.sh /opt/java6
#
# author: Zdenek Obst, zdenek.obst-at-gmail.com
BIN_DIR=/usr/bin
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit
fi
if [[ -z "$1" ]]; then
echo "Pass the new JDK home as the first argument, e.g. /opt/java6"
exit
fi
ACTUAl_JDK_PATH=`ls -l $BIN_DIR/java | awk '{print $11}' | sed 's:\/jre\/bin\/java::g'`
echo "=> Actual JDK path used by symlinks is: $ACTUAl_JDK_PATH"
NEW_JDK_PATH=`echo ${1%/}` # remove last slash if needed
echo "=> New JDK path for symlinks will be: $NEW_JDK_PATH"
read -p "Are suggested JDK paths correct? (y/n) " yn
if [ "$yn" != "y" ]; then
echo "Cancelled on user's request"
exit
fi
echo "----------------------------------------------"
FILES=`ls -l $BIN_DIR | grep $ACTUAl_JDK_PATH`
ls -l $BIN_DIR | grep $ACTUAl_JDK_PATH | while read file;
do
FILENAME=`echo $file | awk '{print $9}'`
SYMLINK=`echo $file | awk '{print $11}'`
ACT=`echo $ACTUAl_JDK_PATH | sed 's:\/:\\\/:g'` # escape characters for SED
NEW=`echo $NEW_JDK_PATH | sed 's:\/:\\\/:g'` # escape characters for SED
NEWLINK=`echo $SYMLINK | sed "s/$ACT/$NEW/g"`
if [ -f $NEWLINK ]; then
echo "-> Replacing symlink: $BIN_DIR/$FILENAME -> $NEWLINK"
rm $BIN_DIR/$FILENAME
ln -s $NEWLINK $BIN_DIR/$FILENAME
else
echo "!! File $NEWLINK does not exist, skipping symlink re-creation"
fi
done
Simple but crude, ensure you have a user bin folder (and that it is on your PATH) create a bash script as follows,
#!/usr/bin/env bash
export JAVA_HOME="/opt/jdk1.8.0"
${JAVA_HOME}/bin/java $@
and make it executable chmod +x bin/java
, but depends on convention that home/bin
trumps /usr/bin
some nice person will edit this? Setting JAVA_HOME
might do it.
some nice person with a rollneck sweater will edit this? Setting JAVA_HOME
might do it.
How do I check which version of the JVM JRuby is running on?
jruby -rjava -e "puts java.lang.System.get_property('java.version')"
prints out 1.8.0
with above setup.
How do I optimise performance (make use of jvm flags)
-
Edit your
.jrubyrc
in $HOME (for global configuration, NB: jruby-complete may also pick up this configuration up, especially if you kick-off ruby-processing with an installed jruby), apparently you can also have a.jrubyrc
in a local folder and that takes precedence. -
Edit
data/jruby_args.txt
in your local folder-XX:+TieredCompilation
on its own seems to work best.