Posts Tagged ‘Java’

What is JAVA_HOME in Ubuntu?

Tuesday, October 21st, 2008

Some Java programs need the environment variable JAVA_HOME, such as Tomcat. In Windows operating system, JAVA_HOME is the directory that the JDK is located. However, in Ubuntu if you install JDK with “sudo apt-get install sun-java6-jdk”, the JDK’s files are extracted to many directories like /usr/bin, /usr/lib, etc. What is JAVA_HOME?

Some people thought it should be /usr because in Windows the Java compiler “javac” is in JAVA_HOMEbinjavac. So in Linux it should be JAVA_HOMEbinjavac and JAVA_HOME=/usr. I don’t think it is the best sulotion. Because I found /usr/bin/javac is not the real Java compiler, it is just a link. I used “ls -l /usr/bin/javac” to see what it links to:

/usr/bin/javac -> /etc/alternatives/javac

And /etc/alternatives/javac is also a link. It links to /usr/lib/jvm/java-6-sun/bin/javac. This is the real Java compiler. And the path is similar to that in Windows. So I think JAVA_HOME should be /usr/lib/jvm/java-6-sun in Ubuntu Linux.

Servlet: Hello World

Tuesday, September 23rd, 2008

Servlet is a Java programme running on the server side. It is used to provide dynamic contents. Like CGI, servlet can receive requests from a client and do some word, send the result to the client. To run servlets you need to install JDK and a web container. The most popular web container is Tomcat. I use Tomcat 5.5 now. (more…)