Chalmers Göteborgs universitet Sektionen för matematik och datavetenskap

Your Location:
The school
 Computer support
  Software

Shortcuts:
Hardware
Software
Howtos
Technical support
Announcements

JDK - Java Development Kit

Java Development Kit is the development environment for the Java programming language supplied by SUN Microsystems. Java is an object oriented programming language that is platform independent.

Getting started

    Here is an example of what you typically have to do before you can compile and run you first Java program.

  • Create a folder for your Java programs in your home directory.
    mkdir ~/java
  • Start rcopt or tomten and select JAVA.

    If you are using rcopt

    • Add the line:
      setenv CLASSPATH ${HOME}/java
      first to the file ~/.rc.user.d/csh/environment.
    • Update your changes with the command reinit.

    If you are using tomten (mkII)

    • Add the line:
      appendgv CLASSPATH /users/cs/andreas/java :
      to the file ~/.rc.user.d/mkII/environment. You may have to create this file altogether. Note /users/cs/andreas should be replaced with the location of your home directory. If you don't know where that is type: echo $HOME and it will be printed out to you.
    • Logout and login again for your changes to take place.
Usage

    How to compile and run a HelloWorld application

  • Create a class HelloWorld in a file called HelloWorld.java.
  • Compile the class into java bytecode with the command:
    javac HelloWorld.java
    This should produce a file called HelloWorld.class.
  • Run the HelloWorld program with the command:
    java HelloWorld
    Note that the HelloWorld.class must lie in a directory listed in the CLASSPATH environment variable, or else the JVM will not find your class.
  • How to compile and run a HelloWorld applet

    Note that you need to use JDK 1.0 for your applets to run in common browsers such as Netscape 3. If you want to use more recent versions of JDK you have to use the appletviewer that comes as a part of the JDK package. At least until other browsers catch up with the development of Java.

  • Write the HelloWorldApplet class in a file called HelloWorldApplet.java.
  • Compile the class with the command:
    javac HelloWorldApplet.java
    This should produce a file called HelloWorldApplet.class
  • Create a webpage that wraps the class with the <applet> tag like this:
    <applet code="HelloWorldApplet.class" width="100" height="30"></applet>
  • View your applet in a browser by loading the webpage or load it into the appletviewer with the command:
    appletviewer applet.html
Related information


Document last modified 2000-11-14 14:24 by Computer Support