Installing JDK 6 Update 10 on debian Lenny November 17, 2008
Posted by maxmil in : Debian, Java , 3 commentsAt the time of writing both the JRE and JDK 6 Update 10 have been released for over a month but are not available on the non-free branch of the official debian testing repositories. I imagine that this is because Lenny is about to go stable and the maintainers are not accepting new versions, only bug fixes.
This is a shame because Update 10 includes a major revamping of client side Java with new look and feels and much improved applets.
Being impatient i wanted to try this out.
Normally to install sun binaries as debian packages i use java-package which nicely prepares a .deb file that i can use dpkg to install. The advantage of this technique is that the new package integrates nicely with the overall system allowing you to use update-alternatives etc.
However, trying this, i found that java-package has not been updated to handle Update 10 either. The problem seems to be that it only works with versions 6 Update X where X is one single digit.
More info can be found here http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504778
For my architecture the solution was to add this to /usr/share/java-package/sun-j2sdk.sh
"jdk-6u10-linux-i586.bin") # SUPPORTED
j2se_version=1.6.0+update10${revision}
j2se_expected_min_size=130
found=true
;;
just after
"jdk-6u"[0-9]"-linux-i586.bin") # SUPPORTED
j2se_version=1.6.0+update${archive_name:6:1}${revision}
j2se_expected_min_size=130
found=true
;;
My architecture is i586, modify this according to yours.
Then, as usuall to prepare, install and set as default.
$ fakeroot make-jpkg jdk-6u10-linux-i586.bin
$ sudo dpkg -i sun-j2sdk1.6_1.6.0+update10_i386.deb
$ sudo update-alternatives java --config
I then wanted to try the new draggable applet feature. So i went to http://java.sun.com/developer/technicalArticles/javase/6u10_applets/ but the demo didn’t work and whats more the page told me that i didn’t have update 10 installed.
However my browser definitely is running the update 10 plugin, as verified on this site.
Could it be because i’m running iceweasel and not firefox?
Getting stdout from Tomcat 6 May 8, 2008
Posted by maxmil in : Java, tomcat , 2 commentsI am using tomcat version 6.0.14 and have been wrestling with its logging facilities. I use Log4J in my application which logs pretty much all i need to my designated log file.
However the other day i had a production error related to a hibernate query. When i turned on the hibernate show_sql property i expected the database queries to show up in the standard output of tomcat.
Since tomcat executes as a service there is no console in this version of tomcat and there is not stdout.log file in [tomcat install directory]/logs. The file used by tomcat is localhost_[datestamp].log, however my queries did not show up there either.
The solution was to add the swallowOutput attribute to my context definition with value “true”.
Open source java properties file translator January 3, 2008
Posted by maxmil in : Java , add a commentMust have a closer look at Attesoro
Generics in Java and C# September 23, 2007
Posted by maxmil in : Java , add a commentBrilliant article for understanding generics and the difference between the implementations in Java and C#.
http://www.jprl.com/Blog/archive/development/2007/Aug-31.html
Missing xalan2.jar in latest debian update of tomcat5.5 September 20, 2007
Posted by maxmil in : Debian, Java , add a commentJust updated tomcat5.5 and several apps starts complaining that they couldn't find the class org.apache.xalan.processor.TransformerFactoryImpl.
This is because xalan2.jar is not in the /usr/share/tomcat5.5/common/libs directory.
The solution for me was to create a soft link to this directory. From /usr/share/tomcat5.5/common/libs
ln -s ../../../java/xalan2.jar xalan2.jar
Initial parameters eclipse July 31, 2007
Posted by maxmil in : Java, eclipse , add a commentAfter continued problems with permGenSpace errors in eclipse i’ve found a configuration that works, initialize eclipse with the following parameters
-vmargs -Xms512m -Xmx512m -XX:MaxPermSize=256m -XX:PermSize=128m
The last two are the important ones (i could probably reduce them but i have 2Gb of RAM so i’m not too bothered).
This is what each parameter does:
ms: initial memory of the application
mx: maximum memory of the application
PermSize: additional memory used by the VM (by default configured to 32Mb)
MaxPermSize: maximum permanent memory
Metatags and cache control better on server July 10, 2007
Posted by maxmil in : Java, html , add a commentIn IE7 i have’nt been able to override the cache of an html page with metatags.<meta http-equiv="pragma" content="no-cache" />It seems that the browser takes no notice of these meta-tags.
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="-1" />
If you are serving pages dynamically (in my case the pages are generated from jsp’s) a way round this is to set the headers of the response in the server. IE does then take notice.<% response.setHeader("pragma", "no-cache"); %>
<% response.setHeader("cache-control", "no-cache"); %>
<% response.setHeader("expires", "0"); %>
Identify java version on remote server and more… March 29, 2007
Posted by maxmil in : Java, jsp , add a commentSystem properties are a useful way of determining information on a remote server.
Paste the following into a jsp deployed on the server…
java.versio = <%= System.getProperty("java.version") %><br>
java.home = <%= System.getProperty("java.home") %><br>
java.vendor = <%= System.getProperty("java.vendor") %><br>
java.vendor.url = <%= System.getProperty("java.vendor.url") %><br>
line.separator = <%= System.getProperty("line.separator") %><br>
os.arch = <%= System.getProperty("os.arch") %><br>
os.name = <%= System.getProperty("os.name") %><br>
os.version = <%= System.getProperty("os.version") %><br>
path.separator = <%= System.getProperty("path.separator") %><br>
user.dir = <%= System.getProperty("user.dir") %><br>
user.home = <%= System.getProperty("user.home") %><br>
user.name = <%= System.getProperty("user.name") %><br>
Simple xsl tranformation example February 1, 2007
Posted by maxmil in : Java , add a comment
import java.io.OutputStream;
import java.io.Reader;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class XSLTrans {
private Reader xml;
private Reader xslt;
private OutputStream out;
public XSLTrans(Reader xml, Reader xslt, OutputStream out) {
super();
this.xml = xml;
this.xslt = xslt;
this.out = out;
}
public void generate() {
try {
StreamResult scrResult = new StreamResult(System.out);
TransformerFactory xformFactory = TransformerFactory.newInstance();
Transformer transformer = xformFactory.newTransformer(new StreamSource(this.xslt));
Source src = new StreamSource(this.xml);
transformer.transform(src, scrResult);
} catch (TransformerConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Exception handling explained January 26, 2007
Posted by maxmil in : Java , add a commentI’ve finally got a clear view of how to work with exceptions thanks to this article:
http://dev2dev.bea.com/pub/a/2006/11/effective-exceptions.html
In resumen these are the main points:
Definitions:
1) Fault: Unrecoverable exception, like database faliure or most io exceptions.
2) Contingency: Recoverable aplication exception, like a validation of data error.
3) Unchecked Exception: Extends java.lang.RuntimeException
4) Checked Exception: Extends java.lang.Exception
Concepts:
1) Faults should throw unchecked exceptions
2) Contingencies should throw checked exceptions
3) For Faults you should implement a fault barrier somewhere up the top of the call stack where all faults will be caught. (In struts an example would be a global error handler)
4) For Faults you should use exception chaining so as not to lose information about the initial error.