This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
(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.
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.
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?
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!
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?
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.
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?
Executive summary: I mount the Windows partitions and make a symbolic link to reference the repository there.
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:
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.