Fork me on GitHub

n. Slang a rough lawless young Kuali developer.
[perhaps variant of Houlihan, Irish surname]
kualiganism n

Blog of an rSmart Java Developer. Full of code examples, solutions, best practices, et al.

Tuesday, September 4, 2012

Updating Default Java via Ubuntu Alternatives

Overview

Recently my page on the Kuali Wiki regarding Updating Default Java via Ubuntu Alternatives was deleted. For my own edification, I'm adding it here. This is how the Ubuntu distribution natively maintains multiple versions of the same software (ie., different versions/flavors of java). I think it's worth noting since it's not entirely straightforward.

Details

Overview

Commands for maintaining the path of commands managed by the ubuntu system. This is important because Jenkins doesn't allow setting a default tool version. Instead, it will use whatever singular version exists. If more than one version exists, then it will default to whatever is set in the path which is managed by ubuntu alternatives. Therefore, if you have more than one JDK that you are using in Jenkins, the default will be managed this way.


Note This is a system-wide change. If every it is required to have a different JDK between different CI jobs, Jenkins facilitates handling this internally with a drop down.

Commands

All of these commands will alter the state of a running ubuntu distribution, so they need to be executed as root (probably using sudo).

List Java Alternatives




Install a New Alternative

This will add a new alternative for java at the /usr/bin/java path using the java located in /var/lib/jenkins/tools/JDK_6/bin/java with a priority of 99. An alternative must be installed and registered before it can be set.




Setting an Alternative

Sets the java alternative manually to /var/lib/jenkins/tools/JDK_6/bin/java



Doing the same for other tools


Ant




Maven




Javac




Enjoy!

I hope this helps others as much as it helped me.

No comments:

Post a Comment