Keyword - Java

Entries feed - Comments feed

Sunday, October 2 2011

How to upgrade Jenkins on Mac OS X (daemon mode)

Jenkins, the continuous integration server, provides a nice package to run it on Mac OS X. It installs as a launch daemon and runs smoothly. But when a new version of Jenkins is available, there is no automatic upgrade feature. So here is how to upgrade this kind of installtion:

  • Download the latest war of Jenkins from the website
  • Stop the Jenkins daemon: in a Terminal window, type
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
  • Copy the downloaded "war" from your download directory to the "/Applications/Jenkins/" folder.
  • Start the Jenkins daemon: in a Terminal window, type
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Once Jenkins has restarted, you should have an up-to-date installation.

Tuesday, March 27 2007

Choix du type d'exception : Checked ou Unchecked

Petite règle qui peut aider au choix du type d'exception entre Checked et Unchecked :

Si l'appelant d'une méthode ne peut rien faire pour résoudre le problème quand une exception est levée, alors rendez cette exception Unchecked [Via]

Pour rappel, une exception est dite Checked quand elle est déclaré dans une clause throws d'une méthode, ce qui permet au compilateur d'effectuer la vérification du traitement des exceptions lors de la compilation. Les exception dites Unchecked, héritent de RuntimeException et servent surtout à signaler des erreurs pour lesquelles la poursuite de l'exécution est difficile, voire impossible.

PS : Un peu de lecture pour les puristes.

Monday, June 5 2006

Babies in Eclipse

When browsing the Eclipse SWT website, you can be a bit surprised... Here is what you can see if you read the SWT 3.2 Plan carrefully :

Eclipse SWT R3.2 Plan

Needless to say, that these babies won't be part of the download...

Tuesday, May 16 2006

JDK 1.5 source code under Eclipse on MacOS X

There is one thing pretty annoying with the Apple Java Development Kit : you don't have access to the source code under . Why ? Simply because doesn't ship it with the JDK and therefore Eclipse cannot discover it. So, what can I do if I want to have the source code linked to the JRE library as it is done automatically under Windows ?

Update 2006-05-20 : Thanks to Cedrik Lime (see the first comment), here is a very simple solution :

  • Go to the Apple Developer Connection, in the downloads page.
  • Download the J2SE 5.0 Release 4 Developer Documentation package. You may have to log on the ADC. Registration is free if you don't have an account.
  • Once downloaded, install it.
  • In Eclipse, go to Window menu and open the Preferences... dialog.
  • Go to Java/Installed JRE panel. You should see a list of the currently detected MacOS X JVMs.
  • Click on the Add... button to add a new JRE definition.
  • Type JDK 1.5.0 in the JRE name field (or whatever you want).
  • Click on the Browse... button and selec the /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home folder.
  • A list a jars must show up. A part of them should have them source attachement filed.
  • Click on the Ok button.
  • Click on the Ok button.

That's it. You have an Eclipse that can show you the JDK source code when you need it. Of course, you don't have access to all the source because, doesn't ship all the JDK source code.

Friday, March 24 2006

Easy search with Javamail

When dealing with message folder, the temptation is strong to re-invent the wheel when it comes to make a search through its messages. One evident solution is to grab all the messages, test against the criteria, and if the message matches, store it for further need.

Since JavaMail 1.1, a search facility has been provided. It is located in the jaxax.mail.search package. To make a complex search, you just create the needed search terms and compose them with a AND or OR operator. The next step is to call the magic method on the message folder : Folder.search(SearchTerm term) that returns an array of Message instance.

It may be look weird to add such complexity to a simple search in a mail folder, but when it comes to term composition, this solution is the most flexible and above all, when you look at your code, the nicest one.

Friday, January 13 2006

Skype buttons for Confluence : the sequel

In a , I have described how to create a simple macro to have a SkypeMe button in Wiki.

To go a step further, here is a more complete macro that covers all the cases offered by : this Confluence macros is based on the documentation.

Here is the skype macro. It takes two parameter :

  1. action : the skype action to perform (mandatory). Valid values are : "call", "add", "chat", "userinfo", "voicemail" and "sendfile".
  2. color : the color of button (optional). Valid values are : "blue" and "green". When omitted, the color is "blue".
#if($param1)
  #set($imagecolor=$param1)
#else
  #set($imagecolor="blue")
#end
<a href="skype:$generalUtil.escapeXml($body)?$param0">
#if($param0 == "call")
  #set($imagefile="http://download.skype.com/share/skypebuttons/buttons/call_${imagecolor}_transparent_70x23.png")
#end
#if($param0 == "add")
  #set($imagefile="http://download.skype.com/share/skypebuttons/buttons/add_${imagecolor}_transparent_118x23.png")
#end
#if($param0 == "chat")
  #set($imagefile="http://download.skype.com/share/skypebuttons/buttons/chat_${imagecolor}_transparent_97x23.png")
#end
#if($param0 == "userinfo")
  #set($imagefile="http://download.skype.com/share/skypebuttons/buttons/userinfo_${imagecolor}_transparent_108x23.png")
#end
#if($param0 == "voicemail")
  #set($imagefile="http://download.skype.com/share/skypebuttons/buttons/voicemail_${imagecolor}_transparent_129x23.png")
#end
#if($param0 == "sendfile")
  #set($imagefile="http://download.skype.com/share/skypebuttons/buttons/sendfile_${imagecolor}_transparent_98x23.png")
#end
<img src="$imagefile" alt="$param0" border="0"/>
</a>

Here is the macro in action

Use in Confluence Overview
{skype:call}steve.jobs{skype} call
{skype:add|green}steve.jobs{skype} add
{skype:chat}steve.jobs{skype} chat
{skype:userinfo|green}steve.jobs{skype} userinfo
{skype:voicemail}steve.jobs{skype} voicemail
{skype:sendfile|green}steve.jobs{skype} Send File

Monday, January 9 2006

Passage à C# .NET

Cela fait maintenant deux semaines que je développe en C# sous Windows .Net. Venant du monde Java, le saut n'est pas aussi grand que pour un nouveau langage, mais C# possède quelques particularités qui nécessitent une petite adaptation. Par contre, le cycle de développement en Windows Form est très proche de ce qui se fait en MFC, donc là pas trop de surprise.

Ainsi donc, voici mes premières impressions :

  • Les notions de délégués et de déclaration d'événements sont propres à C#. La syntaxe s'avère très concise et pratique à utiliser. J'aime particulièrement la gestion automatique de la composition des délégués et la capacité à les invoquer de manier asynchrone très simplement.
  • Les propriétés indexés sont aussi très pratiques : comme le nom le suggère, ces propriétés sont utilisables avec des index numériques ou bien des objets. Encore une fois la syntaxe est ultra-concise.
  • Petit bémol dans toute cette extase de la découverte : j'aurais aimé que propriétés et attributs ne forment qu'un, lorsque c'est nécessaire. Ainsi, la définition d'une propriété pourrait ou non être accompagné de l'attribut sous-jacent. Enfin bon, je pinaille.

En tout cas, ce qui ressort de ces premiers jours avec .Net et Windows Form, c'est que le développement d'application est presque aussi agréable que sous Mac avec Cocoa et XCode.