LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-28-2009, 02:49 AM   #1
yuri16
Member
 
Registered: Jan 2009
Location: Philippines
Posts: 59

Rep: Reputation: 15
Question How do I set JAVA_HOME on JDK location?


I already exported JAVA_HOME to the directory of jdk

Code:
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
but when I tried mvn --version to test if the Apache maven was successfully installed, I got this error message:

Code:
Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/share/doc/sun-java5-jre/JAVA_HOME5-jre/JAVA_HOME5-jre/JAVA_HOME5-jre/JAVA_HOME5-jre/JAVA_HOME/bin/java
Is there something wrong that I did?

Any help will be very much appreciated.
 
Old 01-28-2009, 03:00 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
what is this mvn you are executing?
Obviously, it is setting its own JAVA_HOME.
 
Old 01-28-2009, 03:11 AM   #3
yuri16
Member
 
Registered: Jan 2009
Location: Philippines
Posts: 59

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Agrouf View Post
what is this mvn you are executing?
Obviously, it is setting its own JAVA_HOME.
That was the installation process of Apache Maven.

Let me tell you the instructions:

1. Extract the distribution archive, i.e. apache-maven-2.0.9-bin.tar.gz to the directory you wish to install Maven 2.0.9. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-2.0.9 will be created from the archive.
2. In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-2.0.9.
3. Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.
4. Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.
5. Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH.
6. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.5.0_02 and that $JAVA_HOME/bin is in your PATH environment variable.
7. Run mvn --version to verify that it is correctly installed.

Can you tell me the correct way to set JAVA_HOME and so as the PATH? Coz I'm really confused. Thank you so much.
 
Old 01-28-2009, 03:11 AM   #4
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Something should be wrong in your apache-maven installation:
Code:
bash-3.1# /opt/apache-maven/bin/mvn --version
Maven version: 2.0.9
Java version: 1.6.0_11
OS name: "linux" version: "2.6.27.7-smp" arch: "i386" Family: "unix"
bash-3.1#
Code:
bash-3.1$ set|grep JAVA
JAVA_HOME=/usr/lib/java
bash-3.1$
 
Old 01-28-2009, 03:23 AM   #5
yuri16
Member
 
Registered: Jan 2009
Location: Philippines
Posts: 59

Original Poster
Rep: Reputation: 15
[QUOTE=Didier Spaier;3423745]Something should be wrong in your apache-maven installation:
Code:
bash-3.1# /opt/apache-maven/bin/mvn --version
Maven version: 2.0.9
Java version: 1.6.0_11
OS name: "linux" version: "2.6.27.7-smp" arch: "i386" Family: "unix"
bash-3.1#
When I tried the command below it says "No such file or directory". The Apache Maven was located on /usr/local/apache-maven-2.0.9

Code:
/opt/apache-maven/bin/mvn --version
The things is, the JAVA_HOME was located on /usr/share/doc/sun-java5-jre which I think it should be located on where jdk is (if I'm not mistaken). The jdk was located on /usr/lib/jvm/java-1.5.0-sun
 
Old 01-28-2009, 03:44 AM   #6
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
I am wondering:
- why do you need Apache maven ? What do you intend to do with it ?
- why didn't you get it as a package for your distribution ?
- (take no offense) knowing that you don't know how to export a BASH environment variable neither how-to include a path in your PATH environment variable, how are you going to effectively use Apache maven ?

I issued following command: '/opt/apache-maven/bin/mvn --version' because I knew where the 'mvn' program was on *my* system.

Otherwise please send output of : 'set|grep JAVA' and 'echo $PATH' commands (typed without the quotes).
 
Old 01-28-2009, 03:56 AM   #7
yuri16
Member
 
Registered: Jan 2009
Location: Philippines
Posts: 59

Original Poster
Rep: Reputation: 15
I'm sorry, honestly it was my first time to use linux commands so please bear with me. I need to install Apache Maven because it was a required software for the portal server.

Anyway, here are the outputs:

Code:
gridport:~# set|grep JAVA
JAVA_HOME=/usr/share/doc/sun-java5-jre/JAVA_HOME5-jre/JAVA_HOME5-jre/JAVA_HOME5-jre/JAVA_HOME5-jre/JAVA_HOME
_=JAVA_HOME

Code:
gridport:~# echo $PATH
/usr/local/apache-maven-2.0.9/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/java/jdk1.5.0_07/bin
 
Old 01-28-2009, 04:12 AM   #8
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
It would be helpful if you mentioned the type of distribution you are using. Many of the ones that come with a package manager will set up the path automatically and can install maven from their repositories.
 
Old 01-28-2009, 04:15 AM   #9
yuri16
Member
 
Registered: Jan 2009
Location: Philippines
Posts: 59

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jay73 View Post
It would be helpful if you mentioned the type of distribution you are using. Many of the ones that come with a package manager will set up the path automatically and can install maven from their repositories.
I'm using Debian.
I am installing Debian-based portal server which requires me to install Apache Maven first before to go through the portal installation.
 
Old 01-28-2009, 04:17 AM   #10
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
Right, Debian should have maven. But how did you install java, not manually I hope?
 
Old 01-28-2009, 04:28 AM   #11
yuri16
Member
 
Registered: Jan 2009
Location: Philippines
Posts: 59

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jay73 View Post
Right, Debian should have maven. But how did you install java, not manually I hope?
I used "apt-get install sun-java5-jdk"
 
Old 01-28-2009, 05:11 AM   #12
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
OK, now install maven using apt-get install maven2. You may want to check first whether it is actually available (command = aptitude search maven) but I can hardly imagine that it is not.
You may need to remove the paths that you set manually; unless you have a different jdk as your default, installing jdk5 should have taken care of this part.

Last edited by jay73; 01-28-2009 at 05:12 AM.
 
Old 01-28-2009, 07:04 AM   #13
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Actually, when you export JAVA_HOME, you must do it in the same terminal as the one where you launch mvn
 
Old 01-28-2009, 09:29 PM   #14
yuri16
Member
 
Registered: Jan 2009
Location: Philippines
Posts: 59

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jay73 View Post
OK, now install maven using apt-get install maven2. You may want to check first whether it is actually available (command = aptitude search maven) but I can hardly imagine that it is not.
You may need to remove the paths that you set manually; unless you have a different jdk as your default, installing jdk5 should have taken care of this part.
I don't know how to recover the changes I made in /etc/profile.
I really had a wrong move..so now when I used "vi /etc/profile",
I got this:

Code:
E325: ATTENTION
Found a swap file by the name "/etc/.profile.swp"
          owned by: root   dated: Wed Jan 28 11:53:05 2009
         file name: /etc/profile
          modified: YES
         user name: root   host name: gridport.psigrid.gov.ph
        process ID: 23578
While opening file "/etc/profile"
             dated: Wed Jan 28 17:15:53 2009
      NEWER than swap file!

(1) Another program may be editing the same file.
    If this is the case, be careful not to end up with two
    different instances of the same file when making changes.
    Quit, or continue with caution.

(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /etc/profile"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/etc/.profile.swp"
    to avoid this message.
"/etc/profile" 67 lines, 605 characters
Press ENTER or type command to continue
Code:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

export PATH

unmask 022
On which part of the above script I'll going to add for the setting up of JAVA_HOME??

I'm very confused. I'm really new to this.
 
Old 01-29-2009, 01:29 AM   #15
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
You just add your export JAVA_HOME to the bottom of /etc/profile. As for the first excerpt you posted, that is the message you would get if your vim session crashed. It tells you that a copy of the original file has been made and that you need to decide what to do with it. See the information under (2) in the message.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
JAVA_HOME seems to be getting set somewhere other than /etc/profile Neztec Linux - Newbie 8 10-22-2009 06:42 AM
unable to set JAVA_HOME mahi Linux - Newbie 2 11-17-2008 02:04 AM
Install jdk in different location noshankus Linux - Newbie 3 08-11-2008 01:47 PM
How to set JAVA_HOME for Tomcat Technomot1 Linux - Newbie 2 11-26-2007 03:50 AM
How to set JAVA_HOME in catalina.sh rajaniyer123 Linux - Software 1 10-06-2007 04:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration