5

I am installing RJB by ruby gem on UBUNTU 11.* I added the

export JAVA_HOME=/usr/lib/jvm/java-6-...
export PATH=$PATH:$JAVA_HOME/bin

to the .bashrc file at home directory. But still it throws the err or JAVA_HOME not set.

Does anyone know what is wrong?

echo $JAVA_HOME shows exactly the right path. And I did log on again, even reboot. But still throws the same error.

Tombart
  • 30,520
  • 16
  • 123
  • 136
Sen Han
  • 71
  • 1
  • 5

2 Answers2

6

I've run the same issue in Ubuntu 10.04. What ended up working for me was to su into root and install:

sudo su -
export JAVA_HOME=/usr....
gem install rjb
diegogs
  • 2,036
  • 2
  • 16
  • 20
  • Worked like a charm for me. Apparantly, sudo is not taking all the environment further... thanks for ur tip.. – Raghav Mar 23 '14 at 00:03
0

To make sure that the variable continues to be available after reboot, you can create the following file:

/etc/profile.d/javaenv.sh

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk # <- make sure this path is correct

Now, once your server is rebooted, your JAVA_HOME variable will be available to all users.

If you want to enable it immediately, run:

sudo sh /etc/profile.d/javaenv.sh
Vadim
  • 1,916
  • 2
  • 19
  • 39