Getting, installing and testing the Java SDK - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Getting, installing and testing the Java SDK

Description:

It is set in a similar fashion. ... The bin directory contains the java complier and the java virtual machine. The includes directory has c header file for ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 12
Provided by: daveh177
Category:

less

Transcript and Presenter's Notes

Title: Getting, installing and testing the Java SDK


1
Getting, installing and testing the Java SDK
2
Installing SDK
  • Make sure you have room! (150MB).
  • Download the appropriate file from java.sun.com
  • Get the JDK Standard Edition 1.4.1
  • Java version one is Java 1 and Java 1.1
  • Java version two is Java 1.2, Java 1.3 and Java
    1.4 (Do not be confused by these numbers)
  • Run the file (start the installation). Install
    somewhere easy to access, I like c\jdk1.4
  • Download and install documentation
  • Java 2 SDK Standard Edition documentation.
  • HTML files.

3
PATH Environment Variable
  • To run the tools (compiler, JVM, etc) from the
    DOS command line you need to add the location of
    the tools to your PATH.

4
What is a DOS search path ?
  • The concept of a search path came from DOS, which
    inherited from UNIX, etc
  • The search path is a list of directories that
    DOS/Windows will search for executable files
  • You can view the current search path by creating
    a DOS Prompt (Start Programs MS-DOS Prompt).
    You will see a DOS prompt that looks something
    like
  • C\WINDOWSgt
  • At this prompt, type the command PATH, and you
    will see output similar to the following
  • C\WINDOWSgt PATH
  • PATHC\WINDOWSC\WINDOWS\COMMAND
  • We need to place one of the directories that the
    JDK installation created on the search path,
    specify the bin directory. We do this with the
    command 
  • C\WINDOWSgt PATH C\WINDOWSC\WINDOWS\COMMANDC
    \j2sdk1.4.0

5
CLASSPATH environment variable
  • The Java compiler and VM use the CLASSPATH
    environment variable to decide where to look for
    class definitions (Java code).
  • Very similar to the PATH environment variable in
    DOS
  • It is set in a similar fashion.
  •   The CLASSPATH is kept as a DOS environment
    variable, and can be viewed with the SET
    command. The SET command will display a list of
    all the DOS environment variables and their
    values. The one were interested in is the
    CLASSPATH variable
  • C\WINDOWSgt SET
  • CLASSPATH.C\j2sdk1.4.0C\j2sdk1.4.0\bin ("."
    is the current directory ).
  • This CLASSPATH setting has 3 directories .
    which represents the current directory (whichever
    directory youre working in right now)
    C\jdk1.2, and C\jdk1.2\bin.

6
Batch files to source your environment variables
  • You can use your favorite editor to create a txt
    file in the root directory called
    SETUP4JAVA.bat
  • Insert the following lines into this file
  • _at_ECHO OFF
  • PATH C\WINDOWSC\WINDOWS\COMMANDC\j2sdk1.4.0\b
    in
  • SET CLASSPATH.C\j2sdk1.4.0C\j2sdk1.4.0\bin
  • Now, each time you start an MS-DOS Prompt, you
    only need to type the single command
  • C\WINDOWSgt C\SET4JAVA
  • There are several techniques for setting the
    search path and class path permanently. However,
    these require several steps and can be very
    confusing if you dont already know how to modify
    your environment, so they are not included here.
    Books on Windows can help you in this regard.

7
Testing things
  • Typically you need to reboot to have any changes
    to the PATH take effect.
  • Open a MS-DOS prompt window (command prompt for
    Win2K and up).
  • Type "java version". If you get "unknown
    command" or something like that, your PATH is not
    right

8
Organizing your work
  • In general, you do the following
  • create a folder to hold the java code.
  • Recommended is creating a directory such as
    C\JAVAPROGS, and then additional directories for
    each homework assignment, e.g. C\JAVAPROGS\HW1,
    so your directory structure would look like

9
General process in writing Java
  • use an editor (notepad will work, but other
    editors will work better check out editplus at
    www.editplus.com) to create a Java program. You
    may use commerial packages like Visual Café,
    Jbuilder, and CodeWarrior is a few to mention.
    But most of these add in unnecessary complexity
    and may introduce a new source of error which you
    will not be able to detect.
  • compile the program (using javac)
  • run the program (using java)

10
Example directory Structure of a Windows
installation
  • The bin directory contains the java complier and
    the java virtual machine
  • The includes directory has c header file for
    native code
  • jre (java runtime) has executeable for the
    runtime and also the Class libraries
  • Lib contains some of the class libraries used by
    the run time executables

11
Sun "first cup of Java" tutorial
  • on the web at http//java.sun.com/docs/books/tuto
    rial/getStarted/cupojava/win32.html
  • Goes through all the steps, explains how to
    resolve common problems
Write a Comment
User Comments (0)
About PowerShow.com