Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
Print Button
 

Getting Started

To write any JavaTM program, you need to download the development kit for J2SE for Windows , for Solaris or the The Outlaw Cafe: A Site Devoted to Java Development on the Mac for Mac users.

Development kits are also available in other languages.

Next set up the software, and then configure your system.

  • Instructions to set the variables on a Windows platform
  • Instructions to set up the UNIX or Solaris environment.
  • Instructions for setting up the Mac environment.

    Next you need to learn how to invoke the compiler and interpreter.

    LinkSource
    Compiling and Running a Simple Program Basic Java Programming
    Getting Started The Java Tutorial

    The following three examples use the javac and java commands and illustrate how to compile and run an application, applet, and servlet.

    Application

    Compile the ExampleProgram.java application with the javac command and run it with the java command.
      javac ExampleProgram.java
      java ExampleProgram
    

    Applet

    Compile the SimpleApplet.java applet with the javac command.
      javac SimpleApplet.java
    
    You can run the applet in appletviewer (a Java platform tool for running applets independently of the browser) or in the browser. Either way you need an HTML file for the applet.

    Here is the HTML file:

    <HTML>
    <BODY>
    <APPLET CODE=SimpleApplet.class WIDTH=200 HEIGHT=100>
    </APPLET>
    </BODY>
    </HTML>
    
    To run the applet in the browser, you load the HTML file. To run the applet in appletviewer with an HTML file named simple.html, type this in an MS-DOS window on Windows, or in a terminal window on Solaris:
      appletviewer simple.html
    

    Servlet

    To compile the ExampServlet.java servlet you will also need to install the JavaServerTM Web Development Kit and add it to your class path as you did for the J2SE. Then compile with the javac command.
      javac ExampServlet.java
    
    
    Servlets can be called directly by typing their uniform resource locator (URL) into a browser's location window after you've started the server.

    Servlets can also be invoked from an HTML form by specifying their URL in the definition for a Submit button, for example.

    Servlets can be called by any program that can open an hypertext transfer protocol (HTTP) request.

    chicline

    New-to-Java Programming
    Learning Materials
    JavaTM Platform Overview
    Step-by-Step Programming
    For Web Masters
    Discussion Forums
    Interesting Web Sites
    Software Downloads
    Quick Reference


    Reader Feedback

    Tell us what you think of this information.

    [Duke]

    Very worth reading Worth reading Not worth reading

    If you have other comments or ideas for future articles, please type them here:


  • Print Button
    [ This page was updated: 21-Sep-2000 ]
    Products & APIs | Developer Connection | Docs & Training | Online Support
    Community Discussion | Industry News | Solutions Marketplace | Case Studies
    Glossary | Feedback | A-Z Index
    For more information on Java technology
    and other software from Sun Microsystems, call:
    (800) 786-7638
    Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
    Sun Microsystems, Inc.
    Copyright © 1995-2000 Sun Microsystems, Inc.
    All Rights Reserved. Terms of Use. Privacy Policy.