what should be my JAVA_HOME and what Java should I use (ubuntu)?

1,750 views
Skip to first unread message

oren

unread,
Oct 3, 2010, 8:54:50 PM10/3/10
to Ruboto (JRuby on Android)
I use Ubuntu 10.4, sun-java-6-sdk and RVM.

rake show me this error:

Android SDK Tools Revision 7
Project Target: Android 2.2
API level: 8

------------------
Resolving library dependencies:
------------------
Ordered libraries:
------------------

WARNING: No minSdkVersion value set. Application will install on all
Android versions.

Importing rules file: tools/ant/ant_rules_r3.xml
cp libs/jruby-stdlib-1.5.3.jar generated_libs

-compile-tested-if-test:

-dirs:
Creating output directories if needed...

-pre-build:

-resource-src:
Generating R.java / Manifest.java from the resources...

-aidl:
Compiling aidl files into Java classes...

-pre-compile:

compile:
Compiling 1 source file to /home/oren/misc/projects/test/myapp/bin/
classes
rake aborted!
org.apache.tools.ant.BuildException: 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-sun-1.6.0.20/jre"

ant install show me this error:

BUILD FAILED
/home/oren/misc/apps/android-sdk-linux_x86/tools/ant/ant_rules_r3.xml:
472: The following error occurred while executing this line:
/home/oren/misc/apps/android-sdk-linux_x86/tools/ant/ant_rules_r3.xml:
244: exec returned: 1

which javac
/usr/bin/javac

I try adding this line to .bashrc:
export JAVA_HOME=/usr/bin

but if I do that I can't use jruby at all:
gem list or rake will display:
/home/oren/.rvm/rubies/jruby-1.5.3/bin/jruby: line 358: /usr/bin/bin/
java: No such file or directory
/home/oren/.rvm/rubies/jruby-1.5.3/bin/jruby: line 358: exec: /usr/bin/
bin/java: cannot execute: No such file or directory


any clues would be great!

Scott

unread,
Oct 5, 2010, 3:57:09 PM10/5/10
to Ruboto (JRuby on Android)
I had a similar problem, but it's hard to remember exactly what I
changed. It's definitely a path issue. Check out the following issue
on github:

http://github.com/ruboto/ruboto-core/issues#issue/5

oren

unread,
Oct 9, 2010, 10:50:22 PM10/9/10
to Ruboto (JRuby on Android)
thanks, it's still not working for me. here is my reply in the github
issue:

I am not sure how to make it work.

here is my bashrc:
export JAVA_HOME=/usr
CLASSPATH=$JAVA_HOME/lib/tools.jar
export PATH=/home/oren/misc/apps/android-sdk-linux_x86/tools/:/home/
oren/bin:$PATH

the error i get is:

org.apache.tools.ant.BuildException: 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-sun-1.6.0.20/jre"

what should be the $JAVA_HOME ?
and why it tells me it's in /usr/lib/jvm/java-6-sun-1.6.0.20/jre even
after i set it in bashrc?

Scott

unread,
Oct 10, 2010, 12:51:14 AM10/10/10
to Ruboto (JRuby on Android)
Here's the relevant pieces of my .bashrc:

JRUBY_HOME=/usr/local/lib/jruby
PATH=$PATH:$JRUBY_HOME/bin

ANDROID_HOME=/usr/local/lib/android-sdk-linux_86
PATH=$PATH:$ANDROID_HOME/tools

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

oren

unread,
Oct 10, 2010, 3:43:12 AM10/10/10
to Ruboto (JRuby on Android)
Thanks Scott.
how do i find the my JRUBY_HOME? (i use rvm)


I get the same error after changing my bashrc to these:

ANDROID_HOME=/home/oren/misc/apps/android-sdk-linux_x86
PATH=$PATH:$ANDROID_HOME/tools

AVA_HOME=/usr/lib/jvm/java-6-sun
PATH=$PATH:$JAVA_HOME/bin

export PATH=$PATH:/home/oren/bin

Scott

unread,
Oct 11, 2010, 1:03:08 PM10/11/10
to Ruboto (JRuby on Android)
I'm not using rvm, so I can't comment much there.

What do you see when you type: which jruby

I seem remember an issue related to the jruby jars gem that gets
installed with the ruboto gem. Your gems bin directory ends up in the
path, so you may need to manage where that comes in relation to other
jruby installs. I really don't know how rvm manages it. I remember
having to do a bunch of experimentation until it worked. I also
remember that that error message about JAVA_HOME seemed misleading in
the end.

Here's what my path looks like at the moment:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/
games:/var/lib/gems/1.8/bin/:/home/scott/.gem/ruby/1.8/bin:/usr/local/
lib/jruby/bin:/usr/local/lib/android-sdk-linux_86/tools:/usr/lib/jvm/
java-6-openjdk/bin

oren

unread,
Nov 6, 2010, 9:45:27 PM11/6/10
to Ruboto (JRuby on Android)
here is my .bashrc:

JRUBY_HOME=/home/oren/.rvm/rubies/jruby-1.5.3/bin/jruby
PATH=$PATH:$JRUBY_HOME/bin

ANDROID_HOME=/home/oren/misc/apps/android-sdk-linux_x86
PATH=$PATH:$ANDROID_HOME/tools

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

export PATH=$PATH:/home/oren/bin:/usr/bin

and here is my path:
home/oren/.rvm/gems/jruby-1.5.3@test/bin:/home/oren/.rvm/gems/
jruby-1.5.3@global/bin:/home/oren/.rvm/rubies/jruby-1.5.3/bin:/home/
oren/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/
bin:/usr/games:/home/oren/misc/apps/appengine-java-sdk-1.3.8/bin:/home/
oren/misc/apps/android-sdk-linux_x86/tools:/usr/lib/jvm/java-6-sun/
bin:/home/oren/bin

now i get this error:
compile:
/home/oren/misc/apps/android-sdk-linux_x86/tools/ant/ant_rules_r3.xml:
336: warning: 'includeantruntime' was not set, defaulting to
build.sysclasspath=last; set to false for repeatable builds
Compiling 1 source file to /home/oren/misc/projects/test/myapp/bin/
classes
rake aborted!
org.apache.tools.ant.BuildException: 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-sun-1.6.0.22/jre"

zn...@borasky-research.net

unread,
Nov 7, 2010, 4:37:29 PM11/7/10
to oren, Ruboto (JRuby on Android)
Does "unset JAVA_HOME" fix it?

oren

unread,
Nov 11, 2010, 11:35:11 AM11/11/10
to Ruboto (JRuby on Android)
http://jruby.org/2010/11/10/jruby-1-5-5.html

jruby 1.5.5 is here.
I'll try it and update this thread.

when you say "unset JAVA_HOME",
you mean to try and remove this line from bashrc?


On Nov 7, 9:37 pm, "zn...@borasky-research.net" <zn...@borasky-

oren

unread,
Nov 20, 2010, 7:22:36 PM11/20/10
to Ruboto (JRuby on Android)
not working with 1.5.5 as well (ubuntu 10.10)

here is my .bashrc:

JRUBY_HOME=/home/oren/.rvm/rubies/jruby-1.5.5
PATH=$PATH:$JRUBY_HOME/bin

ANDROID_HOME=/home/oren/misc/apps/android-sdk-linux_x86
PATH=$PATH:$ANDROID_HOME/tools

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

the same error:

M. Edward (Ed) Borasky

unread,
Nov 20, 2010, 7:49:43 PM11/20/10
to rub...@googlegroups.com, oren, Ruboto (JRuby on Android)
So you have the JDK installed? Is it the *Sun* proprietary version, or
one of the "open source" packages? I've found quite a few "glitches"
on openSUSE because I use the Open JDK packages instead of the Sun JDK
packages.
--
M. Edward (Ed) Borasky
http://borasky-research.net http://twitter.com/znmeb

"A mathematician is a device for turning coffee into theorems." - Paul Erdos

oren

unread,
Nov 21, 2010, 4:27:53 AM11/21/10
to Ruboto (JRuby on Android)
I have the jdk and I use the sun's version:

dpkg -l |grep jdk

ii openjdk-6-jre
6b20-1.9.1-1ubuntu3 OpenJDK Java
runtime, using Hotspot JIT
ii openjdk-6-jre-headless
6b20-1.9.1-1ubuntu3 OpenJDK Java
runtime, using Hotspot JIT (headless)
ii openjdk-6-jre-lib
6b20-1.9.1-1ubuntu3 OpenJDK Java runtime
(architecture independent libraries)
ii sun-java6-jdk
6.22-0ubuntu1~10.10 Sun Java(TM)
Development Kit (JDK) 6



update-alternatives --config java

There are 2 choices for the alternative java (providing /usr/bin/
java).

Selection Path Priority
Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061
auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061
manual mode
* 2 /usr/lib/jvm/java-6-sun/jre/bin/java 63
manual mode

M. Edward (Ed) Borasky

unread,
Nov 21, 2010, 5:35:51 AM11/21/10
to rub...@googlegroups.com, oren, Ruboto (JRuby on Android)
It looks like you have a mixed set - your JDK (Java Development Kit)
is the proprietary Sun version but the JRE (Jave Runtime Environment)
is the OpenJDK version. Try uninstalling the OpenJDK JRE packages and
installing the Sun JRE packages. I don't have Ubuntu so I don't know
the exact package names.

"A mathematician is a device for turning coffee into theorems." - Paul Erdos

oren

unread,
Nov 21, 2010, 6:04:59 AM11/21/10
to Ruboto (JRuby on Android)
thanks for the advice Edward.
now I only have these:
sun-java6-jdk
sun-java6-jre

but I get the same error

Scott

unread,
Nov 21, 2010, 4:03:42 PM11/21/10
to Ruboto (JRuby on Android)
Here's my dpkg -l | grep jdk

ii default-jdk
1.6-34 Standard Java or Java
compatible Development
ii openjdk-6-jdk
6b18-1.8.2-4ubuntu2 OpenJDK Development
Kit (JDK)
ii openjdk-6-jre
6b18-1.8.2-4ubuntu2 OpenJDK Java runtime,
using Hotspot JIT
ii openjdk-6-jre-headless
6b18-1.8.2-4ubuntu2 OpenJDK Java runtime,
using Hotspot JIT (hea
ii openjdk-6-jre-lib
6b18-1.8.2-4ubuntu2 OpenJDK Java runtime
(architecture independe

The default-jdk is different. If I type "which javac" I get /usr/bin/
javac

Matt Williams

unread,
Nov 22, 2010, 9:22:11 AM11/22/10
to rub...@googlegroups.com
I have encountered a similar issue.  It was supposed to be fixed at/before 1.5.0 (I believe) but I had to modify the jruby script as follows:

309,312d308
< if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
<     LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
< fi
<
326c322
<   "$JAVA_CMD" $PROFILE_ARGS $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -classpath "$JRUBY_CP$CP_DELIMITER$CP$CP_DELIMITER$CLASSPATH$CP_DELIMITER$LOCALCLASSPATH" \
---
>   "$JAVA_CMD" $PROFILE_ARGS $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -classpath "$JRUBY_CP$CP_DELIMITER$CP$CP_DELIMITER$CLASSPATH" \
349c345
<     "$JAVA_CMD" $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH$CP_DELIMITER$LOCALCLASSPATH" \
---
>     "$JAVA_CMD" $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH" \
362c358
<     exec "$JAVA_CMD" $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH$CP_DELIMITER$LOCALCLASSPATH" \
---
>     exec "$JAVA_CMD" $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH" \

It now works (I encountered this error (among other places) with mariah)

Hope this helps!


alp

unread,
Nov 21, 2010, 6:43:07 AM11/21/10
to Ruboto (JRuby on Android)
sorry for double answering you oren.
Do you have ant installed?

Peter Lamber

unread,
Nov 21, 2010, 6:36:58 AM11/21/10
to rub...@googlegroups.com
hello,
check again if your bin directory of /usr/lib/jvm/java-6-sun-1.6.0.22/jre contains javac.
I think /usr/lib/jvm/java-6-sun-1.6.0.22/jre is not the right one, I'm using this:
/usr/lib/jvm/java-6-sun/.
regards

2010/11/21 oren <oren...@gmail.com>

Matt Williams

unread,
Nov 22, 2010, 2:36:19 PM11/22/10
to rub...@googlegroups.com
On Sun, Nov 21, 2010 at 6:36 AM, Peter Lamber <pla...@googlemail.com> wrote:
hello,
check again if your bin directory of /usr/lib/jvm/java-6-sun-1.6.0.22/jre contains javac.
I think /usr/lib/jvm/java-6-sun-1.6.0.22/jre is not the right one, I'm using this:
/usr/lib/jvm/java-6-sun/.
regards



What I found is that even though my bin directory contained javac, it still failed until I made the change above.

YMMV, of course.

oren

unread,
Nov 25, 2010, 2:58:55 PM11/25/10
to Ruboto (JRuby on Android)
@Scott: I get the same result for which javac: /usr/bin/javac
@alp: yes, I have ant installed
@Peter: I don't have javac in /usr/lib/jvm/java-6-sun-1.6.0.22/jre,
but my in my .bashrc I have:
JAVA_HOME=/usr/lib/jvm/java-6-sun
PATH=$PATH:$JAVA_HOME/bin

so I don't understand why it complains about /usr/lib/jvm/java-6-
sun-1.6.0.22/jre .

@Matt: thanks for the script. I am afraid I don't understand it. is it
part of your bashrc?
it contain all kind of funny characters like > at the beginning of
some lines. sorry for the confusion.

Thanks to all the brave souls that help me!

Peter Lamber

unread,
Nov 26, 2010, 3:53:04 AM11/26/10
to rub...@googlegroups.com
whats the output of echo $PATH and echo $JAVA_HOME ?
...maybe theres a glitch in your bashrc
2010/11/25 oren <oren...@gmail.com>

oren

unread,
Nov 26, 2010, 6:08:15 PM11/26/10
to Ruboto (JRuby on Android)
echo $PATH
/home/oren/.rvm/gems/jruby-1.5.5@test-ruboto/bin:/home/oren/.rvm/gems/
jruby-1.5.5@global/bin:/home/oren/.rvm/rubies/jruby-1.5.5/bin:/home/
oren/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/
bin:/usr/games:/home/oren/misc/apps/appengine-java-sdk-1.3.8/bin:/home/
oren/misc/apps/android-sdk-linux_x86/tools:/usr/lib/jvm/java-6-sun/
bin:/home/oren/bin

echo $JAVA_HOME
/usr/lib/jvm/java-6-sun
Reply all
Reply to author
Forward
0 new messages