David Coldrick's Weblog

     
 
Java Development on Ubuntu - Part 1 - Installing Java
Since the beta of NetBeans 5.0 has been launched, and "Early Availability" versions of Java Studio Creator 2 and Java Studio Enterprise 8 are available, and the next release of Ubuntu is just about out the door, I thought it was time to update my previous post on doing Java development on Ubuntu.

First, I guess some folks might say "Ubuntu? Don't you work for Sun? Why not Solaris X86?". Too easy, I reckon: that's a supported platform, and you should have no problem getting Java and the tools we'll be talking about up and running together on Solaris. For those of you who - like me - are interested in the progress of Linux on the desktop, and would like to have our development tools available in that environment, this is for you. And besides, the new release of Ubuntu is a wonderful desktop on my new Inspiron 9300.

OK, excuses over, let's get to it. Our first step is an easy one, and basically the same as described before. First download the most recent jdk: at the time of writing, this is jdk-1_5_0_05-linux-i586.bin. Be sure to get the .bin, not the .rpm.

Next install - either with synaptics or apt-get or wajig, whatever your preference, the package "java-package": for example, sudo apt-get install java-package. Note that this will also install the package "fakeroot", if you don't already have it installed. Note also that java-package is in "multiverse", so your repository list /etc/apt/sources.list needs to contain, for example:

deb http://au.archive.ubuntu.com/ubuntu breezy multiverse
deb-src http://au.archive.ubuntu.com/ubuntu breezy multiverse

Create a Debian java package with fakeroot make-jpkg, for example

fakeroot make-jpkg jdk-1_5_0_05-linux-i586.bin

Important: don't use sudo to do this, and expect to get some warning/ error "permission denied" messages. This should create a debian package - sun-j2sdk1.5_1.5.0+update05_i386.deb - ready to install with dpkg or wajig. For example,

sudo dpkg -i sun-j2sdk1.5_1.5.0+update05_i386.deb

Once you've installed it, you'll be up and running with the latest jdk: your JAVA_HOME is now, for example, /usr/lib/j2sdk1.5-sun. Get a command line, and enter java -version: you should see something like:

java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

Next installment, NetBeans!

Tags: NetBeans : Java

@ 10:15 AM EST    Permalink [ Comments [35] ]
 
 
 
 
Trackback URL: http://blogs.sun.com/coldrick/entry/java_development_on_ubuntu_part
Comments:

Why do u have to create a .deb package? The .bin installer works straight out of the box. And you might want to download the JDK + NetBeans bundle. It does save some effort. And yes, I installed it on Ubuntu.

Posted by Richard Relos on October 03, 2005 at 07:33 PM EST #

That way other packages installed using the debian package manager that depend on Java will be aware that java is installed.

RE: Why do u have to create a .deb package? The .bin installer works straight out of the box. And you might want to download the JDK + NetBeans bundle. It does save some effort. And yes, I installed it on Ubuntu.

Posted by Zach on October 04, 2005 at 10:17 PM EST #

Hi, Do you have a way to install NetBeans as a deb package? I used to create so lame deb myself for 3.6. It would be nice to have a script like the make-jpkg one.

Posted by Atleta on October 06, 2005 at 07:26 AM EST #

My question is, "Ubuntu? Why not just use Gentoo?"

I know, you're holding your nose. But Gentoo isn't really that hard to install, and a graphical installer is almost here.

After that, installing Java is easy:

emerge "=dev-java/blackdown-jdk"

For the sun JDK it's a two step process:

1) Download JDK and place in /usr/portage/distfiles

2) emerge "=dev-java/sun-jdk"

Keeping up with updates is even easier:

emerge world

See? What could be simpler? (Note the evil grin...)

Posted by Greg Barton on October 07, 2005 at 12:36 AM EST #

hi, thanks for the post. i switched to ubuntu a few months ago and am very happy with it. using hoary, the unofficial ubuntu guide ( http://ubuntuguide.org/#jre ) lists additional repositories, one of which includes the package: sun-j2sdk1.5, which gives you j2sev5update4.

Posted by eitan on October 07, 2005 at 01:24 AM EST #

I followed the instructions, but it seemed the default gcj Java environment conflicted with Sun's. I used Synaptic to remove the java-gcj-compat package and now everything seems dandy.

Posted by Juan C Nuno on October 19, 2005 at 06:33 AM EST #

/etc/ept/sources.list should be /etc/apt/sources.list Thanks Jeremy

Posted by Jeremy Allen on October 20, 2005 at 02:36 PM EST #

I had the same problem described by Juan Nuno. (java -version returns: java version "1.4.2" gij (GNU libgcj) version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)). I followed his instructions and now java -version returns: java version "1.5.0_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05) Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing) Yay!

Posted by Tim Finney on October 23, 2005 at 01:09 PM EST #

Please see Jun Zhang's even better way to recognize the new JDK installation (this weblog, comments, 6 Oct.) I.e.: sudo update-alternatives --config java and choose the appropriate one.

Posted by Tim Finney on November 04, 2005 at 07:41 AM EST #

" /etc/ept/sources.list should be /etc/apt/sources.list": Updated - thanks, Jeremy (musta been using the NZ pronunciation :-) )

Posted by David Coldrick on November 04, 2005 at 09:06 AM EST #

Tim Finney wrote: " Please see Jun Zhang's even better way to recognize the new JDK installation (this weblog, comments, 6 Oct.) I.e.: sudo update-alternatives --config java and choose the appropriate one." Well, that's ok for some things, I guess. But it doesn't change the JAVA_HOME environment variable, and some software depends on that. And it doesn't change the symlink that is /usr/bin/java, and *I* depend on that :-). And "which java" points to that symlink . . . Regards, David

Posted by David Coldrick on November 04, 2005 at 09:12 AM EST #

I'm using Ubuntu, with Java 6 (mustang). Binary snapshots are available (just google it). NetBeans 5 works great on it - much better than with Java 5; the font treatment is much better. See http://blogs.sun.com/roller/page/tor?entry=new_toys_hot_workstation_and. I don't actually install packages; I just unzip the JDK in a directory, and point to it in my etc/netbeans.conf. (I like to have multiple JDK's (and ant's, etc.) installed, and switch between them using aliases and path environment variables.)

Posted by Tor Norbye on November 10, 2005 at 04:24 PM EST #

Your blog must have fired a lot of Ubuntu users to Netbeans. My download of Netbeans IDE is crawling at 2.3KB/sec, and I am at only 1.7MB of 58.7MB !

Posted by Raja Iskandar Shah on November 17, 2005 at 09:16 PM EST #

Thanks for the help. I went down a lot of dead-ends before I found this. Life for a noob can be tough. I'll be glad when I have a couple of years behind me. :)

Posted by Grady Lambert on November 18, 2005 at 09:24 AM EST #

Glad to help, Grady. Enjoy.

Posted by David Coldrick on November 18, 2005 at 10:28 AM EST #

New to Ubuntu, and like what I see. Your instructions to create a .deb package for the JDK5 almost worked. I had to add: source and binary for: http://us.archive.ubuntu.com/ubuntu breezy multiverse (and remove "main restricted universe") in the Synaptic Package Manager (using [x] Show disabled software sources) and then finally java-package was found. After the .deb package was created and installed, and I ran update-alternatives, my cool "click" sounds and system startup/shutdown sounds disappeared. No biggie, but obviously a conflict somewhere. My question is, where is java-package located - do I have to remove main restricted universe (and what are these params for?), and, have I messed up something more important with this? It's easy to rebuild the system now, but the more I use it... So far I'm quite impressed by Ubuntu. Been a RedHat/Fedora guy for years now. But thought I'd investigate this distro.

Posted by Lars on November 30, 2005 at 04:23 PM EST #

Hi Lars, Don't understand why you had to do anything other than add the deb and deb-src for multiverse as I suggested, but anyhoo . . . Again, I don't advise using update-alternatives, in that I haven't done so, and, as I said in a reply above: "Well, that's ok for some things, I guess. But it doesn't change the JAVA_HOME environment variable, and some software depends on that. And it doesn't change the symlink that is /usr/bin/java, and *I* depend on that :-). And "which java" points to that symlink" java-package is purely the package around "make-jpkg": if you want to remove it, use Synaptic. It's *very* unlikly that java-package has anything to do with your loss of sound! However, I dunno about "update-alternatives" Finally, the relevant line in my sources.list that gets me to java-package is deb http://archive.ubuntu.com/ubuntu/ breezy universe main restricted multiverse Be good idea to ask more general questions in the Ubuntu Forums (http://www.ubuntuforums.org/) Enjoy Ubuntu!

Posted by David Coldrick on December 01, 2005 at 09:27 AM EST #

Thanks for the heads up. I used the Synpaptic Package Manager - maybe would have been better to just edit it and add your multiverse link - they're different. I may play "reinstall-it-all" again and retry (playing with Ubuntu with an old laptop for testing). And I do hear you about update-alternatives. I'm always puzzled why distros (include MacOSX) require so much "futzing" to get Java5 to work. It's a wonderful release.

Posted by Lars on December 01, 2005 at 01:17 PM EST #

Hi! good to read something about Java and Ubuntu, didn't know if it was supported. The Synaptic Package Manager makes it really simple :)

Posted by MarkJ on December 19, 2005 at 06:51 AM EST #

To select the newly installed Java (Ubuntu) as your default and keep the exisiting or other versions you need to issue the following command - [sudo update-alternatives --config java] this will ask you which version (shows path also) you want to make your default. you can get a list of the different JVMs etc.. by doing the following - [dpkg -l | grep -i java] hope this helps...

Posted by funkyAde on February 17, 2006 at 10:37 PM EST #

When I try to install Java I get This message: Creating temporary directory: /tmp/make-jpkg.XXXXnKl14q Loading plugins: blackdown-j2re.sh blackdown-j2sdk.sh common.sh ibm-j2re.sh ibm-j2sdk.sh j2re.sh j2sdk.sh j2se.sh sun-j2re.sh sun-j2sdk.sh No matching plugin was found. Removing temporary directory: done

Posted by John on July 17, 2006 at 08:18 PM EST #

Hi John, That looks like what should happen: Have you continued to install the resulting java package? Regards, David

Posted by Coldrick on July 17, 2006 at 08:40 PM EST #

I have been havin all sorts of problems trying to get a copy of the jdk onto my system. I keep coming up against the error message:

Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment.

I can only guess that the installation doesn't know where to look for these files. Doing an env command doesn't show any java specific environment variables ie JAVA_HOME etc.

Any thoughts on what might be a possible solution?

Gary

Posted by Gary J on July 22, 2006 at 11:58 AM EST #

Hi Gary, So what have you done so far? When do these messages appear? Regards, David

Posted by David Coldrick on July 22, 2006 at 08:54 PM EST #

Iniitially I tried to install it straight from the synaptics application builder, then when that caused the Error: could not find libjava.so I tried to follow your steps. Got down to the running of the application but then I typed java -version I get the errors mentioned.

I had to use the sudo update-alternatives --config java function as it was still pointing to the original install when I typed 'which java'.

Gary.

Posted by GaryJ on July 24, 2006 at 12:08 AM EST #

definitely, thank you for the great post!

Posted by owen on September 23, 2006 at 09:15 AM EST #

hi all, was wondering if we need to remove the old jvm that was already installed within the system of ubuntu 6.06 after we installed the latest jdk 1.5 from Sun?

when i do update-alternatives and get the list of the available java i see a "+" sign next to "/usr/lib/jvm/java-gcj/jre/bin/java" what does the "+" sign means? as the "*" is for the default of Sun's java "/usr/lib/j2sdk1.5-sun/bin/java"

last but not least, how do i remove the old existing jvm?

thank you in advance

Posted by Makoto Ishijima on December 06, 2006 at 12:09 PM EST #

It's me again guys, and i need suggestion as i'm new in this linux debian.

the next step that i got confused with is whether to install j2ee package (java_ee_sdk-5_01-linux.bin ) by using "sudo java_ee_sdk-5_01-linux.bin" or i need to make it as a .deb first like the jdk 1.5?

because i'm affraid if i do that the j2ee only be installed on the current folder and it doesn't installed on the system.

this question goes along with the netbeans 5.5, so i make it as .deb first or just do a "sudo xxx.bin"?

your help would be greatly appreciated

Posted by Makoto Ishijima on December 06, 2006 at 12:23 PM EST #

Hi Makoto-san, I don't recommend uninstalling gcj, there may be some dependencies (mind you, you'd be told what they were when you tried to uninstall). Don't bother trying to make debs for NetBeans, etc. I just run the bin file, and I don't use sudo. Netbeans then gets installed in your home directory (by default), and it's easy to control: you can have multiple versions of netbeans, each in different directories if you want. If you want to do the Java EE stuff, I'd suggest you just install the bundle of 5.5 and the app server from http://www.netbeans.info/downloads/index.php?rs=14&p=3 Enjoy, David

Posted by David Coldrick on December 06, 2006 at 05:32 PM EST #

Thank you Mr. David Coldrick, your advice is greatly appreciated and it helps a lot. I have my netbeans installed with the sun app server and its currently runnable (as in i haven't found any problems yet) Now I know where to go if I need help/advice and couldn't get it from any forums or faqs. Have a great one...David-san

Posted by Makoto Ishijima on December 19, 2006 at 07:08 PM EST #

Hi, I am building a private server running ubunto Fiesty. I can't get java5 to install ... actually there is a /etc/java dir so it did install. But the plugins ..component and plugin .so file aren't linked or in their proper directories. I've been trying alot of stuff. Also I did terminal cmd line installs plus the synaptic install of sun-java but that is sun os right? so I went back and did ia32-sun-java5-bin Can you email me some hings here ... Is this being posted to the world? Let's find out.

Posted by caroline kuo on July 25, 2007 at 12:45 PM EST #

Hi Caroline, This post has largely been superseded, in that java is now available from the Ubuntu repositories. With Synaptic, search for sun, the package is called sun-java- something (I'm on a Mac now, don't have Ubuntu running). Regards, DAvid

Posted by David Coldrick on July 25, 2007 at 03:28 PM EST #

I have Ubuntu 7.10 on my laptop. I am trying to use Matlab on desktop but the graphical interface won't appear (just grey square). Reading the ubuntu help tells me that typing "which java" I should get "usr/local/bin" and I get "usr/bin/java". Can you help me to fix this?
Thank You!

Posted by Simo on November 21, 2007 at 07:39 AM EST #

http://www.batteryfast.co.uk/hp/dv9500.htm hp dv9500 battery,
http://www.batteryfast.co.uk/hp/dv9600.htm hp dv9600 battery,
http://www.batteryfast.co.uk/hp/dv9700.htm hp dv9700 battery,

Posted by laptop battery on October 24, 2008 at 05:50 PM EST #

Do you want to own some betteries which have more function , more economical and long life? Please visit the following Web site: http://www.adapterlist.com/hp/dv9100.htm hp dv9100 battery,it will help you find the ideal battery.

Posted by laptop bettery on March 03, 2009 at 05:31 PM EST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed
 
« March 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    
       
Today

[RSS Newsfeed]

Valid XHTML or CSS?

[This is a Roller site]
Theme by Rowell Sotto.
 
© David Coldrick's Weblog