Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, June 11, 2011

Setting up Java in Linux

Setting up Java in Linux can be a real pain when you are an Ubuntu noob. It took me quite some time (nearly a day to be precise) to get it working. After a lot of purges, fresh installs and reboots, its successfully installed. I thought of sharing with you the goldmine "Java installation in Linux made easy" :P

I had initially installed Java from the official site by Oracle but it always gave me a lot of errors whenever I opened Eclipse, saying "Java 6 was not installed". I am sure there were many ways to work around it with a lot of commands etc. But, c'mon let's face it, we are Ubuntu noobs. So, I had to purge the whole installation and cleaned the entire system of Java before starting all over again. This time I used the method mentioned below and it worked.

Open the terminal and install sun java with the command

sudo apt-get install sun-java6-jdk sun-java6-jre

This should the whole sun java installation process. To be on the safer side, after this installation, open Synaptic Package Manager (System>Administrator>Synaptic Package Manager) and search for sun-java6-bin, sun-java6-jre, sun-java6-jdk and sun-java6-plugin. If they are already marked as installed, well and good, otherwise install them. They say the jdk does include the jre and you don't have to install both of them. But, I installed both.

JDK and JRE will mostly be installed at /usr/lib/jvm/java-6-sun-1.6.0.24. Ubuntu will create a symbolic link to java and javac at /usr/bin/java and /usr/bin/javac for easier access.

Next, we have to create a symbolic link to show where Java is installed in the system. This can be done with the following commands.

sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.24/bin/java /usr/bin/java
sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.24/bin/javac /usr/bin/javac

Lastly, you have to set the JAVA_HOME variable. This can be done by opening the .bashrc file in the home directory as superuser and editing by including this line at the end.


export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.24"

Finally, you can check if Java is installed by typing the following command in the terminal


java -version

If it returns the version number of Java installed in your system, then Bingo! You have got Java successfully installed in your system.

Now, you can install your JDK SE or EE bundles from the Oracle site.

Wednesday, May 4, 2011

Ubuntu Synaptic Manager unable to install any new packages

This was a major problem for me in the initial stages as an Ubuntu noob. The synaptic manager simply didn't install any new packages saying there were from unreliable sources. Changing the repositories to global and fiddling with the settings of the Synaptic Manager had no effect. Its a big turn off when you can't install VLC player and other stuff just when you were beginning to think Ubuntu was awesome.

I finally got a way around it last week. I changed the server which was used for the installation of packages. It was set to the default server (server for India). This can be changed by going to System>Synaptic Package Manager>Settings>Repositories>Ubuntu Software>Download from:
Here you choose Other.. and Select Best Server. It will try pinging a few servers and after a few seconds..Bingo! You have got the best server to install packages. For me, it was somewhere in Indonesia!

I cannot guarantee whether this might work for you. But, if changing repositories and other settings in Software Sources doesn't get you anywhere, try this out.