Java
JDK6 installation without running the installer
As a Java developer, I often need to install JDKs, and often I need them to exist in parallel in different versions. At least for Windows, it’s only possible to download installers as EXEs that will install both the JDK and the JRE on your computer. Each time they run, they will put java.exe and a couple of other files into the windows installation directory in order to provide globally callable Java executables. WTF. I believe that this is not only a convenience mechanism for the end user, but also a way to force people to accept license agreements etc. by clicking a button. I do always accept those agreements, although I regard the fact that I’ve clicked a button in an application a really fragile agreement between me and the publishing company. So, I performed some experiments and it is of course possible to get all the required files without really running the installer. I can assemble my JDK and use it, bypassing the installer which messes with my system. So far so good. It’s quite a bit of work to do so, but it works in the end. I won’t publish the steps here.
Now for the question: dear Oracle, Sun, or whatever you may wish to be called – why can’t you simply put a checkbox on your website, a checkbox that allows me to agree to your terms and conditions, and then give me a ZIP that I can simply extract and use? Please! I know that this was possible in the past. Come on, it can’t be that hard, can it?
Comments welcome.
Sun, or Oracle, JDK installer fail
In case you run into trouble because you used the Windows x64 JDK6 installer and you can’t uninstall, here’s what I did: I uninstalled the JRE first, which made it impossible to uninstall the JDK, all I got was an error 1723. Looking into the windows event log, I saw that the JDK uninstaller tried to load a regutils.dll from JAVA_HOME/jre/bin/ – which was not there any more because I had already uninstalled the JRE. I copied the JRE folder back to the installation location and then I was able to uninstall the JDK as well.
Don’t get confused if you use Google because most forum postings will tell you to update the Windows Installer etc. etc., this is probably senseless, especially if you – like me – have a completely up to date Windows 7 on your box.
JBoss 4.2.3, JDK 6, JAX-WS
Just a quick note on what not necessarily to do if you intend to deploy applications using webservices on JBoss 4.2.3. JBoss 4.2.3 comes in two flavours, selectable from the download page:
- JBoss 4.2.3
- JBoss 4.2.3 JDK6
The latter contains a couple additional JARs in lib/endorsed:
- jaxb-api.jar
- jboss-jaxrpc.jar
- jboss-jaxws.jar
- jboss-jaxws-ext.jar
- jboss-saaj.jar
The release notes contain some hidden hints that the JDK6 version of JBoss 4.2.3 is still experimental. Those JARs, especially the jaxws JARs, contain implementations that appear to be under active development. Looking at the source code reveals some pretty “hacky” portions of code here and there. The downside of those JARs is that if you have an application that contains libraries like CXF or Axis, you might run into severe trouble because the JBoss implementation of classes like javax.xml.ws.Service gets loaded first, instead of the version you have packaged with your application. You can of course tune the classloading options of your app, which MAY resolve the problem, but it does not necessarily help you a lot – you will either have to package a whole bunch of additional JARs with the application, or you will simply not make it around the classes from lib/endorsed.
My opinion at the moment is this: unless you have a very good reason OR an application that is completely based on the JBoss JAXWS et alii implementations anyway, simply use the “normal” JBoss 4.2.3, which is compiled against JDK 5 and does not bring along those libraries. On the web, you will most likely find hints like “delete the *jaxws*.jar from lib/endorsed” – actually, why delete them, if you can download the version that was compiled against JDK5. Comments?
SCJP rants
Hello world,
I’m currently preparing for CX-310-065, you name it, “Sun Certified Programmer for the Java Platform, Standard Edition 6″. It’s interesting to learn about the gory details of Java, although it does sometimes require a good bit of Buddha-like meditation to make it through the SCJP dungeon. Here’s why:
- Many of the exam questions seem to be pure tests for the trained eye. Most of the example code would blast into red x’es in Eclipse, or whatever icon your favourite IDE would put in place. Are there any serious Java programmers out there using vi?
- Getting the voucher is a WoW-like quest. If you live in Germany, you cannot order the voucher via Sun’s US website. (Which they tell you only as soon as you log in, and then your shopping cart is automatically emptied) If you order the voucher from the german website, you are under the impression that you are ordering a voucher for a german test. Bad if you are preparing using an english book.
- There are different conditions regarding the exam. If you take the english version, you are given a lower number of questions. The amount of correct answers for both versions is roughly equivalent if you express it in percent.
- You have to schedule and take the exam via Prometric – they have an ultra-slow website. Waiting for 2 to 3 minutes between pages is not uncommon. Additionally, I remember the site going down all the time while I was taking my JBoss test in 2007.
- If you have made it through the Prometric website and you did NOT get the voucher beforehand, you have to go back all the way, feeling a slight bit of pain because you didn’t realize that you CAN NOT buy a voucher directly from Prometric – they do have pricing information on their site though.
In the end, putting aside all the technical trouble and the mix of information you find on the various SUN websites, I’m a little concerned with the title I’m going to earn – “Certified Programmer” sounds pretty nice, but as soon as you pass the exam, you won’t have written a single line of Java code, unless you have tried some of the examples from the various books. Good for me that I’ve been collecting development experience for about two and a half years by now, this makes the certificate a sensible … certificate :-) And of course it’s a prerequisite for the higher levels of certification, like the SCWCD, Sun Certified Web Component Developer, which I’m going to tackle in the near future. Wish me luck for the exam. Thanks :-)
Java network programming shizzle
Anyone want to know what is the best way to do network programming in Java?
› Continue reading
Hibernate cascade options
I just read about 85% of the Hibernate reference documentation because I couldn’t find any information on the cascade options you can set in your mapping file. Here’s what I found and where I found it:
Chapter 5.1.12 “many-to-one”:
Setting a value of the
cascadeattribute to any meaningful value other thannonewill propagate certain operations to the associated object. The meaningful values are the names of Hibernate’s basic operations,persist, merge, delete, save-update, evict, replicate, lock, refresh, as well as the special valuesdelete-orphanandalland comma-separated combinations of operation names, for example,cascade="persist,merge,evict"orcascade="all,delete-orphan". See Section 10.11, “Transitive persistence” for a full explanation. Note that single valued associations (many-to-one and one-to-one associations) do not support orphan delete.
Section 10.11 does indeed explain quite a lot about cascading. I simply wanted a collection of child objects to be deleted as soon as the parent is deleted, so I’ve now set the cascade option on the list mapping to “all, delete-orphan”.
Exception-Handling Antipatterns
Exception handling in Java is a very useful, yet often misunderstood mechanism. I wouldn’t call myself an exception(al) expert in this area either. While googling for something related to exception handling, I found this article today:
Tim McClune on Exception-Handling Antipatterns
Tim provides several examples of the most common mistakes or bad-coding-fails as far as exception handling is concerned. Read it! :)
JBoss MBeans + jconsole + JMX
jconsole is a handy tool for taking a quick look at JMX data provided by running Java processes. Although jconsole (JDK5) features a very ugly GUI, it’s still nice to play with. It should well be good enough if you just want to take a quick look at memory consumption or trigger some management methods on MBeans. Well, MBeans, the buzzword deluxe as far as JBoss is concerned – I wanted to see MBeans registered in a running JBoss 4.0.x in jconsole. This is not quite simple because you need to specify several additional options in the run.sh/run.bat. Thanks to this and this, I got it working like this:
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote" JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver" JAVA_OPTS="$JAVA_OPTS -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"
In Windows environments (run.bat), the syntax is – of course – slightly different. In Eclipse, simply add those options to the server configuration.
Just in case you’d like to do some MBean/JMX voodoo with the Spring framework, try the MBeanExporter. I’ll write a couple of sentences about that as soon as my own experiments are done.
Have fun :-)
Trainings Galore
I took part in two interesting and entertaining trainings during the last two weeks, both highly relevant for my daily work.
The first training I went to was a SCRUM master certification training with Jeff Sutherland and Serge Beaumont (Xebia). It took place in Utrecht on November 13th/14th. Utrecht is quite a nice city, I will go there again next year and look at it in more detail. Next time I travel to the Netherlands, I’ll go by train or helicopter – 90 minutes on the way back for 30 kilometers is too much :-) The SCRUM training itself was quite packed with entertaining stories and hands-on exercises and I learned a lot about team dynamics. As we have been doing SCRUM at work for some weeks now, I’m keen to see how this method of working will develop. After my return home, I immediately started doing SCRUM at home as well – very useful to get things done :-)
This week (November 18-21) we had an in-house Core Spring training with Mike Wiesner, who is a very good trainer as well. The training was very well structured with labs for each topic. SpringSource does not only give a complete set of slides to every participant, but also a printed guide for the labs and a complete Eclipse-based development environment with prepared lab projects and complete solutions. Four days of condensed input gave me quite a bit of brain load, but I think it was well worth the time. I also learned a lot about what I have been using in my projects for almost two years now. I will take the “Certified Spring Professional” exam as soon as possible. The training participation certificate will then be exchanged with the “real” certificate :-)
Thanks to all trainers for their good work!
Enum vs Javadoc
Inspired by a work-related question, I tried to add Javadoc to an Enum. In fact, I simply followed the example found in the first Google search result, but nevertheless here is how to do it:
package demo; /** * This Enum is documented * @author myself */ public enum DocumentedEnum { /**First entry*/ FIRST, /**Second entry*/ SECOND }
Look at the image to see what Javadoc makes of it (standard parts removed):
I think this is quite nice.
