Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Linux / UNIX and the fly likes Problems with Java Home in VMBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Problems with Java Home in VMBox" Watch "Problems with Java Home in VMBox" New topic

Problems with Java Home in VMBox

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345


I have some trobles in getting Java Home to work on my VMBox that has Ubuntu. Following is what I have on my /etc/profile and /etc/bash.bashrc

When I say javac on a terminal, below is what I get.

I checked with my Ubuntu dual boot partition and there it seems to work fine for the same settings in /etc/profile but why not here on the VMBox?

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 9929

export JAVA_HOME=/opt/Softwares/jdk1.6.0_21/bin/java
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/Softwares/jdk1.6.0.21/bin

These 2 lines contradict each other. One refers to jdk1.6.0_21 folder and the other to jdk1.6.0.21 (note the . instead of _). Looks like a typo in those files. You'll have to fix it to point to the correct location.

[My Blog] [JavaRanch Journal]
Peter Johnson

Joined: May 14, 2008
Posts: 5812

Also, JAVA_HOME should be set to the installation directory, not to the location of the java executable:

export JAVA_HOME=/opt/Softwares/jdk1.6.0_21

Then when setting the PATH, never reset it, just add the new value. Also, use the prior env vars:

export PATH=$PATH:$JAVA_HOME/bin

JBoss In Action
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345

Looks like I need to get my eyes checked. Thanks for pointing out the typo.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345

And then the next problem: Setting Maven Home

And this is what I get when I say mvn --version

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345

Changed my Java Home like Peter mentioned above and then everything started to work fine.
I agree. Here's the link:
subject: Problems with Java Home in VMBox
Similar Threads
Error starting Tomcat in Ubuntu
Installing Java / Eclipse / Tomcat / Maven on Ubuntu 9.10
Error in Java Home in Ubuntu
IntelliJ startup problems in Ubuntu
Eclipse on Debian Sarge