- 45% is good for Java
- 27% is bad for Java
- 27% should not affect Java
A blog that describes various tips and tricks I have learned over time. They have all helped me and may help you.
Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts
Saturday, October 23, 2010
POLL: Oracle owning SUN (Results)
Monday, June 29, 2009
Netbeans 6.7 Is Here
Today I downloaded and installed Netbeans 6.7. My first impressions are very good. The performance seems better and I really like what was done for unit testing.
I have used it under Windows and Linux. Thanks Netbeans team!! Another great version delivered right on time.
I have used it under Windows and Linux. Thanks Netbeans team!! Another great version delivered right on time.
Sunday, May 31, 2009
Subversion - Checking out a Project
Overview
When it is time to get work done, code will need to be checked out. The main steps to checkout code that was imported as described in a previous post is as follows:
The following steps will checkout the sqlbuilder project that is part of the perl repo into my local filesystem's sqlbuilder folder.
Create new folder called sqlbuilder. My code is targeted to be on my local file system in a base directory of ~/work/perl/sqlbuilder
cd ~/work/perl/
mkdir sqlbuilder
cd sqlbuilder
svn checkout https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/ ./
Now your code is in a subversion managed folder.
Tagging Current Trunk
Tagging is a common practice in which you create a snapshot of your code as it stood in time or within a version. In this example, the sqlbuilder code needs to be tagged. The tagged version will be stored in the repo within a 20090528 folder.
svn -m 'tagging first release' copy https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/ https://www.inhouse.stoken.net/repos/perl/sqlbuilder/tags/20090528
Use a browser to view trunk and tag using the above URLs.
Final Thoughts
The process of checking out a tagged version is the same as for a trunk version, just ensure that the URL path is correct and it will work.
I personally tag frequently in Subversion since Subversion does it pretty efficiently. Your thoughts may vary on this.
This concludes the series on basic Subversion usage. When I have time, I will post something on Subversion + Netbeans. Netbeans handles Subversion very well but there are few small details that may help. I will post them soon.
When it is time to get work done, code will need to be checked out. The main steps to checkout code that was imported as described in a previous post is as follows:
- Create a workspace folder for your project
- Change directory into that folder
- Checkout code from the trunk (or tag or even branch) into the current directory.
The following steps will checkout the sqlbuilder project that is part of the perl repo into my local filesystem's sqlbuilder folder.
Create new folder called sqlbuilder. My code is targeted to be on my local file system in a base directory of ~/work/perl/sqlbuilder
cd ~/work/perl/
mkdir sqlbuilder
cd sqlbuilder
svn checkout https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/ ./
Now your code is in a subversion managed folder.
Tagging Current Trunk
Tagging is a common practice in which you create a snapshot of your code as it stood in time or within a version. In this example, the sqlbuilder code needs to be tagged. The tagged version will be stored in the repo within a 20090528 folder.
svn -m 'tagging first release' copy https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/ https://www.inhouse.stoken.net/repos/perl/sqlbuilder/tags/20090528
Use a browser to view trunk and tag using the above URLs.
Final Thoughts
The process of checking out a tagged version is the same as for a trunk version, just ensure that the URL path is correct and it will work.
I personally tag frequently in Subversion since Subversion does it pretty efficiently. Your thoughts may vary on this.
This concludes the series on basic Subversion usage. When I have time, I will post something on Subversion + Netbeans. Netbeans handles Subversion very well but there are few small details that may help. I will post them soon.
Subversion - Importing a new Project
Overview
Once a repo has been created, it is time to import your code. This has only a few main steps.
In this example, I have created a simple helper project called sqlbuider.
As described above, the first step is to create the base directory within the repo.
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder
Next, the standard subversion directory tree needs to be created.
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/branches
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/tags
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk
If you are building your repo as you are reading along, you should be able to point your browser to it and see an empty folder for .../tags .../trunk .../branches
We are ready for the next step, Import the project. On the local system, change directory to local project folder (sqlbuilder in my case) and import. My local source happens to be in ~/work/perl/sqlbuilder. Subversion doesn't care about the location. Just that you are sitting in the project folder. The following will import the project
cd ~/work/perl/sqlbuilder
svn -m 'inital import' import ./ https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/
The command says, "using the message of 'initial import', import everything in ./ to https://..../trunk/
If you refresh your broswer in the trunk folder, you will see code.
Normally, I will take my local directory (sqlbuilder in my case) and rename it to something like sqlbuilder_pre_svn or sqlbuilder_old.
This process can be followed for multiple projects within the same repo. Just create the directory structure and then import your code into it.
When you are ready to work on the project, you will want to create a new sqlbuilder folder and checkout the https://..../trunk/ code into it. That will be described in my next post.
Final Thoughts
Why not import the folder sqlbuilder? Why import just the contents of the folder into trunk? The main reason is that it simplifies situations where you may have one or many versions of the same project checked out. Now you can checkout a trunk or tag version into whatever directory you want. It makes things easier to deal with. The only thing to remember is to check out after you create a local workspace folder before checking out into it.
The next post will describe howto check out and tag code.
Once a repo has been created, it is time to import your code. This has only a few main steps.
- Create a base directory within the repo with the project name
- Build the standard subversion project tree (tags, branches, trunk)
- Import code into trunk
In this example, I have created a simple helper project called sqlbuider.
As described above, the first step is to create the base directory within the repo.
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder
Next, the standard subversion directory tree needs to be created.
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/branches
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/tags
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk
If you are building your repo as you are reading along, you should be able to point your browser to it and see an empty folder for .../tags .../trunk .../branches
We are ready for the next step, Import the project. On the local system, change directory to local project folder (sqlbuilder in my case) and import. My local source happens to be in ~/work/perl/sqlbuilder. Subversion doesn't care about the location. Just that you are sitting in the project folder. The following will import the project
cd ~/work/perl/sqlbuilder
svn -m 'inital import' import ./ https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/
The command says, "using the message of 'initial import', import everything in ./ to https://..../trunk/
If you refresh your broswer in the trunk folder, you will see code.
Normally, I will take my local directory (sqlbuilder in my case) and rename it to something like sqlbuilder_pre_svn or sqlbuilder_old.
This process can be followed for multiple projects within the same repo. Just create the directory structure and then import your code into it.
When you are ready to work on the project, you will want to create a new sqlbuilder folder and checkout the https://..../trunk/ code into it. That will be described in my next post.
Final Thoughts
Why not import the folder sqlbuilder? Why import just the contents of the folder into trunk? The main reason is that it simplifies situations where you may have one or many versions of the same project checked out. Now you can checkout a trunk or tag version into whatever directory you want. It makes things easier to deal with. The only thing to remember is to check out after you create a local workspace folder before checking out into it.
The next post will describe howto check out and tag code.
Subversion - Adding a new Repo
Overview
Based on my previous post, you should now have a working and configured Subversion environment. Most of the work was done in Apache.
Now a repo is needed to store all related projects. Subversion is pretty flexible here. You can create a repo per project, on single repo for everything, or do what I do. Create a repo per language you work in. For example:
Procedure
For this example, I am adding a new repo for my perl code projects. All my repos are stored in /opt/intranet/svn/
to create a new repo:
• cd /opt/intranet/svn
• svnadmin create perl
• chown -R apache:apache perl/
Within each repo, one or many projects. The following shows how to prepare and import files into a new project.
Final Thoughts
With this repo created, new projects can be added.
Based on my previous post, you should now have a working and configured Subversion environment. Most of the work was done in Apache.
Now a repo is needed to store all related projects. Subversion is pretty flexible here. You can create a repo per project, on single repo for everything, or do what I do. Create a repo per language you work in. For example:
- /opt/intranet/svn/python/
- /opt/intranet/svn/ruby/
- /opt/intranet/svn/java/
- /opt/intranet/svn/php/
Procedure
For this example, I am adding a new repo for my perl code projects. All my repos are stored in /opt/intranet/svn/
to create a new repo:
• cd /opt/intranet/svn
• svnadmin create perl
• chown -R apache:apache perl/
Within each repo, one or many projects. The following shows how to prepare and import files into a new project.
Final Thoughts
With this repo created, new projects can be added.
Saturday, May 30, 2009
Subversion - Setting up Apache and Users
Overview
Subversion is a fantastic source control system. Not only is it pretty easy to setup and use but it also integrates with a vast list of IDEs.
This post describes how to setup the base environment for Subversion. This consists of:
My environment:
When you install Subversion, there will be a default subversion.conf file setup (most likely) in /etc/httpd/conf.d/ for Apache
Within the environment I use, the following file system structure is used:
# START OF CONFIG
<Location /repos>
DAV svn
SVNParentPath /opt/intranet/svn
# Limit write permission to list of valid users.
<LimitExcept GET PROPFIND OPTIONS REPORT>
# Require SSL connection for password protection.
SSLRequireSSL
AuthType Basic
AuthName "StoKen Software Subversion"
AuthUserFile /opt/intranet/svn/users.passwd
Require valid-user
</LimitExcept>
</Location>
# END OF CONFIG
Adding a Subversion User
# htpasswd -c /opt/intranet/svn/users.passwd thawk
New password: mypassword
Re-type new password: mypassword
Adding password for user thawk
Final Thoughts
With this step complete, subversion is ready but will not do anything interesting until you add some repos. But that is another post...
Subversion is a fantastic source control system. Not only is it pretty easy to setup and use but it also integrates with a vast list of IDEs.
This post describes how to setup the base environment for Subversion. This consists of:
- Apache Configuration
- Apache Web Server User
My environment:
- Internal access only
- linux/Unix environment
- Apache + Subversion
When you install Subversion, there will be a default subversion.conf file setup (most likely) in /etc/httpd/conf.d/ for Apache
Within the environment I use, the following file system structure is used:
- /opt/intranet/svn - Main area for subversion repos. Local file system.
- /repos - Apache reference to Parent Path
- /opt/intranet/svn/users.passwd - Location of subversion user/password file for any/all repos.
# START OF CONFIG
<Location /repos>
DAV svn
SVNParentPath /opt/intranet/svn
# Limit write permission to list of valid users.
<LimitExcept GET PROPFIND OPTIONS REPORT>
# Require SSL connection for password protection.
SSLRequireSSL
AuthType Basic
AuthName "StoKen Software Subversion"
AuthUserFile /opt/intranet/svn/users.passwd
Require valid-user
</LimitExcept>
</Location>
# END OF CONFIG
Adding a Subversion User
# htpasswd -c /opt/intranet/svn/users.passwd thawk
New password: mypassword
Re-type new password: mypassword
Adding password for user thawk
Final Thoughts
With this step complete, subversion is ready but will not do anything interesting until you add some repos. But that is another post...
POLL: What Persistance Engine Do you Use? (Results)
- 50% Java Persistence API
- 37% Hibernate (Java)
- 25% NHibernate (.NET)
- 0% LINQ (.NET) 0 (0%)
- 12% ActiveRecord (Ruby)
- 12% Other
POLL: What JAVA Do you use? (Results)
This was not much of a surprise. SUN Java is the way to go. I just hope Oracle continues the to support JAVA like SUN did.
- 90% SUN Java (linux/Windows)
- 5% OpenJDK
- 0% SUN Java (OSX)
- 5% IcedTea (linux)
Tuesday, November 18, 2008
POLL: What Languages do you code in? (Results)
It doesn't come as much surprise how many Java programmers are out there. I am also happy to see so many Ruby developers.
- 89% Java
- 36% C/C++
- 24% C#
- 16% Perl
- 14% Ruby
- 12% Python
- 8% Assembler
- 4% VB
- 0% Objective-C
- 0% ADA
- 0% COBOL
- 0% LISP
Friday, October 17, 2008
POLL: What build system do you use? (Results)
I am pretty surprised how many people use Maven. I am hoping to get it to work better for Swing apps then it does.
- 75% Ant
- 25% Maven
- 25% Other
- 16% make/imake/nmake
POLL: What OS do you develop JAVA on? (Results)
Ubuntu is really getting up there in Java Developers.
- 34% Windows XP
- 27% Linux (Ubuntu)
- 27% OSX 10.5
- 10% Linux (Fedora)
- 10% Linux (SUSE)
- 10% Linux
- 13% Windows Vista
- 06% Other
- 00% OSX 10.x
POLL: What Version of Netbeans do you use? (Results)
Here are the results from our poll of Netbeans version used.
- 73% 6.0
- 19% I don't use Netbeans
- 14% 5.5/5.5.1
- 03% 5.0
- 01% 4.x
POLL: Standard Projects you work on? (Results)
Of all the developers working on projects, the following gives a breakdown. Note that users could vote on more then one type so the total will be greater then 100%
- 70% Swing/GUI
- 40% WEB/JSP
- 40% Console
- 30% Mobile Devices
Monday, April 28, 2008
Netbeans 6.1
I install Netbeans 6.1 today and it delivers all expected. A few points, then I want to get back to playing...
I am very happy. Well back to it.
UPDATE: I have been using Netbeans 6.1 for about a month. Several weeks ago, I switch to Ubuntu Linux 8.04 too. Both are working very very well.
- It starts faster
- It runs faster
- It looks clean
- It has improved code complete
- ....
I am very happy. Well back to it.
UPDATE: I have been using Netbeans 6.1 for about a month. Several weeks ago, I switch to Ubuntu Linux 8.04 too. Both are working very very well.
Wednesday, February 27, 2008
HOWTO: create data aware applications in NetBeans 6.0
Roumen Strobl created a very clear and easy to follow flash demo describing how to create data aware applications using NetBeans 6.0. In the demo, Roumen covers 3 topics:
Somewhere on this page you will find a link to Roumen's weblog. It is on my "bookmark me" list.
- Process for connecting to a MySQL database
- Steps to create a "data aware" Swing Application that talks to MySQL
- Steps to create a REST based web service for accessing the same database
Somewhere on this page you will find a link to Roumen's weblog. It is on my "bookmark me" list.
Labels:
HOWTO,
JAVA,
NETBEANS,
PROGRAMMING,
SWING,
WEBSERVICE
Sunday, February 24, 2008
SOLUTION: Web Service Testing in Netbeans 6.0.1 gets ClassNotFound Exception
Overview
Recently, I have been working on creating some web services using NetBeans 6.0/6.0.1. I have done this before and I wasn't creating anything to crazy. I decided to try them out using the new handy Web Services feature that is in the Services tab of the NetBeans 6.0.1 IDE. Within this feature, you can add a WSDL file and look at the features available for consumption from the web service. My favorite aspect of this is that you can right click on any method and test it. A form opens so you can provide parameters. Once submitted, results are returned in an object. This object can be drilled into for more details.
Using this testing feature, I ran into an odd issue however. I created a new WS that I wanted to experiment with. Again, nothing fancy. When I setup the WS in the NetBeans Web Services area, they were added without errors. However, when I tested them, I got a ClassNotFound exception. I looked at everything but got the same results. I even deployed them on a different server that is running a newer build of Tomcat but got the same results. I wrote a simple client that consumed the WS and it _did_ work...? That was not expected. I looked that the issue from many different angles but could not see an obvious cause. Then something occurred to me...
Workaround
My web service name was all lowercase. Since a web service can be considered a class so it should start with an upper case character. This is normally my convention however, this was just a simple experiment.
Basically, I had something like:
https://www.inhouse.headache.net/timezonews/convertWS?wsdl
That should have been like:
https://www.inhouse.headache.net/timezonews/ConvertWS?wsdl
Once I created my Web Service to start with an upper case character, everything worked. I have not read to see if a web service MUST start with an upper case character. If anyone knows the answer, please post
Final Thoughts
This was an odd issue that I ran into using NetBeans. I hope anyone out there who runs into the same thing reads this solution before they lose to much time.
Happy developing using NetBeans.
Recently, I have been working on creating some web services using NetBeans 6.0/6.0.1. I have done this before and I wasn't creating anything to crazy. I decided to try them out using the new handy Web Services feature that is in the Services tab of the NetBeans 6.0.1 IDE. Within this feature, you can add a WSDL file and look at the features available for consumption from the web service. My favorite aspect of this is that you can right click on any method and test it. A form opens so you can provide parameters. Once submitted, results are returned in an object. This object can be drilled into for more details.
Using this testing feature, I ran into an odd issue however. I created a new WS that I wanted to experiment with. Again, nothing fancy. When I setup the WS in the NetBeans Web Services area, they were added without errors. However, when I tested them, I got a ClassNotFound exception. I looked at everything but got the same results. I even deployed them on a different server that is running a newer build of Tomcat but got the same results. I wrote a simple client that consumed the WS and it _did_ work...? That was not expected. I looked that the issue from many different angles but could not see an obvious cause. Then something occurred to me...
Workaround
My web service name was all lowercase. Since a web service can be considered a class so it should start with an upper case character. This is normally my convention however, this was just a simple experiment.
Basically, I had something like:
https://www.inhouse.headache.net/timezonews/convertWS?wsdl
That should have been like:
https://www.inhouse.headache.net/timezonews/ConvertWS?wsdl
Once I created my Web Service to start with an upper case character, everything worked. I have not read to see if a web service MUST start with an upper case character. If anyone knows the answer, please post
Final Thoughts
This was an odd issue that I ran into using NetBeans. I hope anyone out there who runs into the same thing reads this solution before they lose to much time.
Happy developing using NetBeans.
Monday, January 7, 2008
POLL: What is your favorite IDE (Results)
After several month of polling the favorite IDE results in in.
- 65% Netbeans
- 30% Eclipse
- 2% Microsoft Visual Studio
- 2% IBM Visual Age
Monday, October 29, 2007
Apple - When will OS X Leopard have JAVA 6
When I first started reading about leopard, the new iMAC became the iDrool in my eyes. Everything looked to be there. I was itching to get a MAC to use along side linux. Possibly even replace it over time.
When I found out that JAVA 6 was not included because Apple did not have it ready in time for leopard, I became concerned. I used to use OS/2 and found that same thing. I would see a new version of something come out for other operating systems and finally OS/2 month later. It was just not a priority. I don't like the idea of MAC becoming the same thing. MAC should be cutting-edge. As far as I can see, they are cutting-edge except for this JAVA 6 in leopard issue.
I personally wish that Apple would:
13949712720901ForOSX is here because of this.
When I found out that JAVA 6 was not included because Apple did not have it ready in time for leopard, I became concerned. I used to use OS/2 and found that same thing. I would see a new version of something come out for other operating systems and finally OS/2 month later. It was just not a priority. I don't like the idea of MAC becoming the same thing. MAC should be cutting-edge. As far as I can see, they are cutting-edge except for this JAVA 6 in leopard issue.
I personally wish that Apple would:
- address why it was not included via some kind of press release.
- tell developers and users where JAVA stands in their vision of OSX. Is it core to the OS or a "nice to have" toy?
- tell us what consumers/developers can expect with future releases. (delay or availability when it is officially released by SUN). Are delays going to be a common experience for JAVA developers.
13949712720901ForOSX is here because of this.
Friday, October 26, 2007
Java Everywhere - SUN Microsystems
I found this on Igor Minar's blog. Not only is this nicely put together but I can buy into it.
Enjoy!
Enjoy!
Friday, October 5, 2007
HOWTO: install/upgrade SUN Java under linux
Overview
For those of us using a flavor of linux that does not come with SUN Java (which is currently most of us), you may have run into a bit of a problem. Linux distros typically bundle the the GCC GCJ compiler. Sure, it is probably nice and all but I personally prefer SUN Java. It is what is installed on most non-linux based computers out there. It is the standard.
I, like others out there, have probably tried to remove GCJ from their systems. Well, it is not easy since everything Java that comes with the distro is bound to it. Arg!
The next option is to see if you can get SUN Java and GCJ to co-exist, so you install SUN Java anyway, and run
java -version. You still see GCJ's version. Arg! Why? because the GCJ's java is in the path.
You could setup all the path and JAVA_HOME/JAVA_PATH environment variable but, for me, that is just not enough. I want my environment to just use SUN Java. Outside of simply having 1 flavor of Java installed, this is the way to go. Make SUN Java the default Java.
Purpose
The following will describe the rather simple process for getting SUN Java to be the default Java. This is being done under Fedora Core 6 and 7 (RPM based), however, the technique should work for other distros. I am using SUN Java JDK 6 and am upgrading from 6u2 to 6u3. The process of upgrade or install is the same except for removing the old version :-) The most important aspect is the steps to follow.
Required Downloads
The example will be done installing SUN Java JDK 6 Update 3 (6u3) to replace SUN Java JDK 6 Update 2 (6u2).
Install/Upgrade
Creating your own sun-compat RPM (where sun-compat <> JDK)
Well, you were eager and could not wait for the jpackage guys to create a java-1.6.0-sun-compat-1.6.0.03-1jpp.i586.rpm for you. You just want the latest JDK working. Sound like me. No problems. You have already download the source file (java-1.6.0-sun-compat-1.6.0.02-1jpp.src.rpm or similar) so you can make your own. You have also installed it (3rd bullet above).
To make your own sun-compat RPM just do the following:
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
That is it.
Clean-Up After Successfull Install/Upgrade
Once you are sure everything is using the new version, you can (if desired) rpm -e your old jdk. Since SUN JDK 6 creates a symlink from the current version as "latest" there isn't much risk of using the old version... I did say "much" risk. I prefer removing the old once I confirm the new one is safe and stable.
Netbeans
To tell programs like Netbeans (we are all using it after all) to use the new JDK, simply update the JDK version in $NETBEANS_HOME/etc/netbeans.conf where $NETBEANS_HOME is the location of the netbeans install. That will affect all users of that install globally.
Java WebStart
I love WebStart, however, for some odd reason, desktop shortcuts created for linux (GNOME) hard code the full path (including version) to the javaws program. This is stupid since they should really just point to "latest". Regardless, you can either de-install/re-install the Java WebStart apps, or do the lazy approach and just edit the *.desktop files in your ~/Desktop/ directory. Just update the JDK version to match the current version.
Final Thoughts
This may seem like a long process but the steps are basic and easy. I keep the sun-compat source installed on my system and update the version number each time a new JDK comes out. I only get a new src and i586 version for new major JDK releases (i.e. JDK 5 to JDK 6). This makes the update process take a few minutes. About the same time it takes in Windows to update the PATH of the System Environment.
I hope these steps help it become easier for you too. I also hope that this blog become obsolete and that linux distros start bundling real SUN Java by default. It just the right thing to do. Some distros are already doing this. Fedora? Do you hear this? :-)
BTW
For Ubuntu, this may work. I need to try it.
http://coffeecokeandcode.blogspot.com/2008/09/installing-java-6-update-10-on-ubuntu.html
For those of us using a flavor of linux that does not come with SUN Java (which is currently most of us), you may have run into a bit of a problem. Linux distros typically bundle the the GCC GCJ compiler. Sure, it is probably nice and all but I personally prefer SUN Java. It is what is installed on most non-linux based computers out there. It is the standard.
I, like others out there, have probably tried to remove GCJ from their systems. Well, it is not easy since everything Java that comes with the distro is bound to it. Arg!
The next option is to see if you can get SUN Java and GCJ to co-exist, so you install SUN Java anyway, and run
java -version. You still see GCJ's version. Arg! Why? because the GCJ's java is in the path.
You could setup all the path and JAVA_HOME/JAVA_PATH environment variable but, for me, that is just not enough. I want my environment to just use SUN Java. Outside of simply having 1 flavor of Java installed, this is the way to go. Make SUN Java the default Java.
Purpose
The following will describe the rather simple process for getting SUN Java to be the default Java. This is being done under Fedora Core 6 and 7 (RPM based), however, the technique should work for other distros. I am using SUN Java JDK 6 and am upgrading from 6u2 to 6u3. The process of upgrade or install is the same except for removing the old version :-) The most important aspect is the steps to follow.
Required Downloads
The example will be done installing SUN Java JDK 6 Update 3 (6u3) to replace SUN Java JDK 6 Update 2 (6u2).
- download SUN Java
- Site: http://java.sun.com/
- I used the RPM based install package called jdk-6u3-linux-i586-rpm.bin
- download java-1.6.0-sun-compat-1.6.0.xx-1jpp.i586.rpm where xx is your update version (01, 02, 03,..)
- Site: http://www.jpackage.org/browser/
- In this case, we are trying to download a sun-compat for JDK 1.6.0.03 or 6u3. That is what I hope to find...
- If a version for your JDK is not available, go on to step #3. This is my case for this example.
- download the source file java-1.6.0-sun-compat-1.6.0.xx-1jpp.src.rpm where xx is the latest available version.
- Site: http://www.jpackage.org/browser/
- At the time of the writing, 1.6.0.02 was the only sun-compat available which is a version behind 6u3. This is ok.
Install/Upgrade
- Install SUN JAVA
- command: sh jdk-6u3-linux-i586-rpm.bin
- agree to the terms by typing "yes"
- You will see it install a bunch of RPMs into /usr/java/ and /opt/sun/
- If your java 1.6.0-sun-compat RPM version matches your JDK...
- command: rpm -Uvh java-1.6.0-sun-compat-1.6.0.03-1jpp.i586.rpm
- you are done
- If it does not match then install...
- command: rpm -ivh java-1.6.0-sun-compat-1.6.0.02-1jpp.src.rpm
- as above, version 02 was the only version availble
- you are not done yet.
Creating your own sun-compat RPM (where sun-compat <> JDK)
Well, you were eager and could not wait for the jpackage guys to create a java-1.6.0-sun-compat-1.6.0.03-1jpp.i586.rpm for you. You just want the latest JDK working. Sound like me. No problems. You have already download the source file (java-1.6.0-sun-compat-1.6.0.02-1jpp.src.rpm or similar) so you can make your own. You have also installed it (3rd bullet above).
To make your own sun-compat RPM just do the following:
- cd to /usr/src/redhat/SPECS/ (the source directory may be different on other distros)
- edit java-1.6.0-sun-compat.spec using your favorite text editor
- At the top of the file you will see %define buildver 02
- For this example we want 6u3 so buildver should be changed from "02" to "03".
- Save and close the file.
- Make your RPM
- command: rpmbuild -ba java-1.6.0-sun-compat.spec
- stuff happens...
- Look in /usr/src/redhat/RPMS/i586/ and you will see java-1.6.0-sun-compat-1.6.0.03-1jpp.i586.rpm
- install it
- command: rpm -Uvh java-1.6.0-sun-compat-1.6.0.03-1jpp.i586.rpm
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
That is it.
Clean-Up After Successfull Install/Upgrade
Once you are sure everything is using the new version, you can (if desired) rpm -e your old jdk. Since SUN JDK 6 creates a symlink from the current version as "latest" there isn't much risk of using the old version... I did say "much" risk. I prefer removing the old once I confirm the new one is safe and stable.
Netbeans
To tell programs like Netbeans (we are all using it after all) to use the new JDK, simply update the JDK version in $NETBEANS_HOME/etc/netbeans.conf where $NETBEANS_HOME is the location of the netbeans install. That will affect all users of that install globally.
Java WebStart
I love WebStart, however, for some odd reason, desktop shortcuts created for linux (GNOME) hard code the full path (including version) to the javaws program. This is stupid since they should really just point to "latest". Regardless, you can either de-install/re-install the Java WebStart apps, or do the lazy approach and just edit the *.desktop files in your ~/Desktop/ directory. Just update the JDK version to match the current version.
Final Thoughts
This may seem like a long process but the steps are basic and easy. I keep the sun-compat source installed on my system and update the version number each time a new JDK comes out. I only get a new src and i586 version for new major JDK releases (i.e. JDK 5 to JDK 6). This makes the update process take a few minutes. About the same time it takes in Windows to update the PATH of the System Environment.
I hope these steps help it become easier for you too. I also hope that this blog become obsolete and that linux distros start bundling real SUN Java by default. It just the right thing to do. Some distros are already doing this. Fedora? Do you hear this? :-)
BTW
For Ubuntu, this may work. I need to try it.
http://coffeecokeandcode.blogspot.com/2008/09/installing-java-6-update-10-on-ubuntu.html
Subscribe to:
Posts (Atom)