• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Installing Java / Eclipse / Tomcat / Maven on Ubuntu 9.10

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found this article http://ubuntuforums.org/showthread.php?t=1113039

Will be trying this tonight!
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would the export option work as well to set the Maven Home?
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it. Thanks for the reply! Danke!
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got the following error when I tried it,
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So finally got rid of this problem. Modified the JAVA_HOME accordingly.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks once again for the mention.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic