File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes Installing Java / Eclipse / Tomcat / Maven on Ubuntu 9.10 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Installing Java / Eclipse / Tomcat / Maven on Ubuntu 9.10" Watch "Installing Java / Eclipse / Tomcat / Maven on Ubuntu 9.10" New topic
Author

Installing Java / Eclipse / Tomcat / Maven on Ubuntu 9.10

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Guys,

I would like to install JDK 1.6 on my Ubuntu partition. I did try googling around for ways to do that but most of them pointed out to use sudo apt-get. What I already did is that to download the jdk binaries and I have them in the /downloads directory. I would like to proceed from here. Normally in Windows I have a seperate partition in which I install all my Java related stuff. In the same way I would like to install all Java related stuff in a location which makes sense. I'm thinking of putting it under /usr/local/. Is this good enough? Linux experts, please guide me in getting this installed and the JAVA_HOME to be set. Appreciate your help!


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Found this article http://ubuntuforums.org/showthread.php?t=1113039

Will be trying this tonight!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Here is what I do:

I first download the *.bin file from the http://java.sun.com/javase/downloads/. My downloads always got to Desktop, but that doesn't matter here.

I then open a terminal and enter:



(Replace the '*' in the above with the actual name)

Let me repeat the above steps in paragraph form:
Create a /usr/java directory and install the JDK into it. Then create a 'default' symbolic link to the JDK home directory. In /usr/bin, add symbolic links for java, jar and perhaps some of the other tools in java_home/bin.

Finally, in .bashrc (or similar file) set JAVA_HOME to /usr/java/current.

My placement of the JDK follows where the JDK gets installed in RHEL and Fedora. If you download the JDK RPM from Sun's web site and use that to install, that is where it places it.

By the way, since /usr/bin/java (and the other apps) and JAVA_HOME all reference /usr/java/default, when you install another version of the JDK all you have to do after running the jdk*.bin is switch /usr/java/default to it - no need to reset the app links nor change JAVA_HOME - they are already correct.


JBoss In Action
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Thanks Peter. I tried to follow the website link that I have posted and later found your reply. Anyways, got it successfully installed. Now next step would be to get Maven installed.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I guess it would be pretty much the same like I did when I installed java. Just download Maven, unpack the contents and move it to the desired location and then set the MAVEN_HOME.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

For Maven, Tomcat, Eclipse, etc, I place those in /opt. But first I change the ownership to my user id. And I always get them from their respective web sites, I never use the Ubuntu repository nor apt-get to install them.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I some how messed that up initially but later managed to get this done somehow. Did the following to install Maven.

(1) Downloaded the maven 2.2.1 tar.gz file from apache maven website
(2) Untarred it in the same location (under /home/username/Downloads) using the command tar -zxvf apachemaven.tar.gz
(3) Moved the untarred contents to the location under /usr/local/

Now how do I set the classpath for Maven? I mean I want to set MAVEN_HOME so that I could call mvn tasks and goals from the terminal. Any ideas on how to do this?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Peter Johnson wrote:For Maven, Tomcat, Eclipse, etc, I place those in /opt. But first I change the ownership to my user id. And I always get them from their respective web sites, I never use the Ubuntu repository nor apt-get to install them.


Peter is there any reason as to why you place it under /opt? I have already placed that under /usr/local/. Would this make any difference? I'm just waiting for your reply after which I would change accordingly and set my M2_HOME. Thanks for the help!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Just did a bit of googling and came to know that /opt is kind of Program Files equivalent in windows. Well, then why did I install java under /usr/java? I could very well done that under /opt/java?? Am I right?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Would the export option work as well to set the Maven Home?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Actually, /usr is the area where programs that come with the distro tend to get installed. Like I wrote earlier I use /usr/java because that is where i was used to it appearing in Fedora and RHEL when installing the JDK RPM. The /opt directory is meant for optional software packages installed by the user, so that is where I usually place all the stuff that I download and install myself.

You can leave Maven where you placed it, just set M2_HOME to /usr/local/apache-maven-2.2.1/bin

One of the reasons I put everything in /opt is that I share much of the /opt contents between Windows and Linux when i dual-boot. This way I have only one installation of Maven, for example, that is used in Linux and Windows. I do the same for M2_REPO - one repository of JARs shared by both OSes. Of course you have to be careful that the app can handle this - Eclipse can't so I end up with separate Eclipse installs for Linux and Windows.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I got it. Thanks for the reply! Danke!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Now I'm facing troubles with setting Maven Home. Even after setting M2_HOME, I'm not able to execute mvn --version. I have the following in my profile under /etc/



Is there anything that I'm missing here? Help!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Got the following error when I tried it,
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

After adding the M2_HOME to the path, the path looks like this in profile



And now getting the following message when giving mvn --version


Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

So finally got rid of this problem. Modified the JAVA_HOME accordingly.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

It would be better is you set your path like this:



Then, when you update the JDK you only have to change JAVA_HOME because the PATH will pick up the new setting. Ditto for updating Maven.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Thanks once again for the mention.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Peter, just another question to you. You just mentioned in your post above that you have just one local maven repository shared between your windows system and the linux system. Can you please let me know on how I could acheive that? I have a windows partition (around 20 GB) and I have just kept that as my local maven repository and I have in the past already created projects using that as the local repository which means that I have most of my jars there. Now how can I expose this to the linux partition? I mean I want to specify this windows partition with a folder called MavenRepository to be specified as the local repository for all my builds from the linux partition? How can I do this?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Executive summary: I mount the Windows partitions and make a symbolic link to reference the repository there.

Details:
While installing Ubuntu, on the disk partition, I alway choose manual partitioning. Then, besides creating the swap partition and the root partition, I also edit the Windows partition indicating that it is NTFS and that I want it mounted at /mnt/win7 (in the case of my laptop). The installation script then sets up /etc/fstab for me. Of course, I could always mount it later by adding it to my /etc/fstab file and creating the /mnt/win7 directory. Here is the line in fstab:



or this would work as well



Once the mount is established, it is simple to use 'ln -s' to create a repository directory in the location expected. For example:

ln -s /mnt/win7/User/peter/.m2/repository ~/.m2/repository

However, I dislike having the repository showing up under my account. So I always edit the ~/.m2/settings.xml file to specify a different location, usually at /opt/m2_repo. (In Windows, this is c:\opt\m2_repo on my laptop byt d:\opt\m2_repo on my desktop.) Then the 'ln -s' becomes:

ln -s /mnt/win7/opt/m2_repo /opt/m2_repo

Though lately I have been thinking of moving m2_repo out of /opt, perhaps locating it at /data/m2_repo. I tend to backup /opt and having to ignore /opt/m2_repo (which I never back up , it is easy to recreate) gets to be a hassle.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Thanks for the details. But since I'm running Ubuntu on my VirtualBox, is is just by editing the /mnt/fstab that I could acheive this? Anyways, I would try this today after work.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

I usually don't share files/directories between a Linux VM and its Windows host. But googling for linux mount windows share should yield some helpful advice.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Installing Java / Eclipse / Tomcat / Maven on Ubuntu 9.10
 
Similar Threads
Reclaiming Disk space in Vista
Mac Book Pro - Suggestions needed
IntelliJ Community edition
Installing Softwares & Updating Ubuntu
Laptop? Where should I buy? India or USA?