6

When I built the Jikes RVM on Ubuntu, I got this error. Any idea?

bin/buildit localhost production
---> Config: production
/bin/bash --login -c  '/bin/bash --login -c  "   cd /home/jack/Programs/jikesrvm-3.1.2 &&  export JAVA_HOME=/opt/jdk1.6.0 &&   ant very-clean -Dhost.name=ia32-linux &&  ant check-components-properties -Dhost.name=ia32-linux -Dtarget.name=ia32-linux -Dcomponents.cache.dir=/home/jack/.buildit_components_cache  &&   ant -Dtarget.name=ia32-linux -Dconfig.name=production -Dhg.revision= -Dhost.name=ia32-linux -Dcomponents.cache.dir=/home/jack/.buildit_components_cache "' 
Error: JAVA_HOME is not defined correctly.
  We cannot execute /opt/jdk1.6.0/bin/java
Wed Jun 13 12:23:37 EDT 2012
===================== Summary =====================
Local   : /home/jack/Programs/jikesrvm-3.1.2
Build   : ubuntu:/home/jack/Programs/jikesrvm-3.1.2
Target  : ubuntu:/home/jack/Programs/jikesrvm-3.1.2
Start   : Wed Jun 13 12:23:37 EDT 2012
Config  : production [FAILED Wed Jun 13 12:23:37 EDT 2012]
===================================================

OS:

Linux ubuntu 2.6.32-24-generic #39-Ubuntu SMP Wed Jul 28 06:07:29 UTC 2010 i686 GNU/Linux

Environmental Variables: PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun-1.6.0.22/bin<

JAVA_HOME

/usr/lib/jvm/java-6-sun-1.6.0.22

I checked the java in the JAVA_HOME/bin directory, it works. No matter how I change the environmental variables, the error kept complaining

"We cannot execute /opt/jdk1.6.0/bin/java".

It seems that I didn't modify the right "position".

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
JackWM
  • 10,085
  • 22
  • 65
  • 92

4 Answers4

7

run this command:

find . -exec grep "jdk1.6.0" {} \;

To find out which file is setting JAVA_HOME to that path.

Rocky Pulley
  • 22,531
  • 20
  • 68
  • 106
  • Hi Rocky, following your command, I got this: global.javahome.ia32-linux=/opt/jdk1.6.0 global.javahome.x86_64-linux=/opt/jdk1.6.0 But what are they? How can I change them? Thanks! – JackWM Jun 13 '12 at 19:44
  • Sorry I guess you should add the -l option so you can see the file it's defined in: find . -exec grep -l "jdk1.6.0" {} \; that will print the file name, then edit that file. – Rocky Pulley Jun 13 '12 at 19:56
  • I find them. They are in /bin/buildit.base_config. After modifying them to the real JAVA_HOME, the error disappears. Thanks! – JackWM Jun 13 '12 at 19:58
  • I am facing a similar question:http://stackoverflow.com/questions/29456149/build-openjdk-on-mac-java-home-is-not-defined-correctly?noredirect=1#comment47077297_29456149 and it seems that this solution does not work for me. Could you please take a look? – Boli-CS Apr 06 '15 at 01:43
3

While you build jikes you can either build it using ant or using the command you are using. If the JAVA_HOME problem is causing trouble use

bin/buildit localhost production -j"path to your jvm directory"

-This is present in "/usr/bin/jvm".

Another method: There is bin/buildit.base_config in which path for JAVA_HOME is specifically mentioned. So under "# Default JAVA_HOME values" you can modify appropriate location, for example,

global.javahome.ppc32-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.ppc64-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.ia32-linux=/usr/lib/jvm/java-6-sun-1.6.0.26
global.javahome.x86_64-linux=/usr/lib/jvm/java-6-sun-1.6.0.26

You can chose which you want to use. If not familiar with your architecture, modify all and now you can build without having to worry about your java path to be mentioned explicitly. For more detailed information check this blog

I have also written a small article on how one can start to fiddle with Jikes

Community
  • 1
  • 1
Pankaj Sejwal
  • 1,605
  • 1
  • 18
  • 27
  • @jackWM: There is presently bug in jikes while building it with openjdk 7 and its working fine with version 6, so use version 6. – Pankaj Sejwal Jul 06 '12 at 05:51
0

It's JRE but not JDK. Install JDK and make JAVA_HOME pointing to it.

Artem Oboturov
  • 4,344
  • 2
  • 30
  • 48
-1

You might get this error due to couple of reasons. To fix this quickly please follow below steps,

First find the java location. To get a list of your installed Java platforms, run the following command from the terminal:

$ sudo update-alternatives --config java

Now set JAVA_HOME and PATH,

$ export JAVA_HOME=<java_home>

$ export PATH=$JAVA_HOME/jre/bin:$PATH

Create the symlink

$ sudo ln -s <java_home>/jre <java_symlink_path>

When we take your case as a example :

$ sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.22/jre /opt/jdk1.6.0

Above command will create the symlink location where the system is trying to find in your issue.

Finally do the try your app.

tk_
  • 16,415
  • 8
  • 80
  • 90