DOC

Installing Java and JCreator

By Joseph Patterson,2014-04-24 12:02
10 views 0
Installing Java and JCreator

Installing Java and JCreator

You have access to lab machines that have these tools (or similar ones) installed, but many of you may

    want to install it on your own machines. These instructions are for those running Windows. For those with

    Mac's, you'll need to make sure that your machine has Java 1.5 installed. If you are using something

    besides Mac or Windows and still need help installing Java 1.5, see your instructor.

Installing J2SE 5.0 (Java 2 Standard Edition 5.0)

    ? If you do not have Java 5.0 update 4 installed on your machine, you will need to download it from

    the Sun site (http://java.sun.com/j2se/1.5.0/download.jsp).

    ? If you have previous installs (of previous 5.0's or any other edition of Java), uninstall it using

    Windows Add/Remove Programs unless you are completely comfortable with managing multiple

    versions of Java on your machine.

    ? Once you've navigated to the Sun page listed above, there will be a few options you want the

    one entitled “JDK 5.0 Update 4”. Click on Download JDK 5.0 Update 4 to get to the next page.

    ? Accept the license agreement, and select the download for the platform you will be using. For

    Windows, there are two options offline and online installations. If you wish to download the

    entire install file at once so that the install can be without a connection to the internet, select

    “Windows Offline Installation”. If you do not wish to download this large file and would rather do

    the install over a network connection, select “Windows Online Installation”. Also note that those

    running Windows on an AMD64 machine have an additional option at the bottom of the page.

    ? Once you have downloaded the file, run the executable. The install should progress like most

    program installs. You need to remember where it installs the SDK. In Windows, this is typically

    C:\Program Files\Java\jdk1.5.0_04\ (if installing update 4).

    ? Now you must adjust some system settings so that Windows knows where to look when you try to

    use the java compiler as well as the run time environment. To accomplish this in Windows, you

    modify an “environment variable” called “path”.

    ? Windows 2000/XP - to set the path permanently, choose Start ==> Settings ==> Control Panel

    and double click on System. Select the Advanced tab and click on the Environment Variables

    button. Look for "path" in the system variables. The new path takes effect in each new Command

    Prompt window you open after setting the PATH variable. Click on the Edit… button, move to the

    end of the path and type

    ;C:\j2sdk1.4.2_03\bin

    ? Windows 98/95 - : Start the system editor. Choose “Start”, “Run” and enter sysedit, then click OK. The system editor starts up with several windows showing. Go to the window that is displaying

    AUTOEXEC.BAT. Look for the PATH statement. At the end of this statement, type:

    ;C:\j2sdk1.4.2_03\bin

    ( To make the path take effect in the current Command Prompt window, execute the following:

    C:> \autoexec.bat ) To find out the current value of your PATH, to see if it took effect, at the

    command prompt, type: C:> path

Now you should be able to use the programs located in the bin (binary) folder of your Java folder in order

    to compile and run your Java programs. You can do this in two ways through the use of a basic text editor and the command line or by using an Integrated Development Environment (IDE). First we show how to do

    it the old fashioned way before we move on to the IDE approach.

Command-line and Text Editor

Once you've successfully installed your JDK, you are ready to create your first program. Open a simple text

    editor (textpad or wordpad, for example), and create a file called “HelloWorld.java”. Enter the following

    code into the file:

public class HelloWorld {

    public static void main(String [] args) { System.out.println(“Hello World!”);

    }

    }

Save the file and open a command line interface. In Windows, you'll want to run the cmd command or find

    the Command Prompt option in Accessories. Change into the directory in which you created your

    HelloWorld.java file, and run the following command: > javac HelloWorld.java

    This compiles the file you created using the javac compiler from your Java JDK. If there are no errors,

    there should now be a file called HelloWorld.class in your current directory. Now run the following

    command:

    > java HelloWorld

    This command runs the compiled HelloWorld code through the Java runtime environment. You should see

    the following output to your command line:

    Hello World!

    Of course, compiling and running programs can be much more complicated. For a brief listing of some of

    the options, issue the commands javac and java without any arguments. Now let's develop a similar program using an IDE.

JCreator

Installation:

    ? Point your browser to http://www.jcreator.com/download.htm

    ? Download JCreator LE version v3.50 build 3.50.013. This should download a file named

    jcrea350.zip.

    ? Unzip the file and run the setup executable.

    ? After installing, run JCreator. Hopefully it will auto-detect your Java JDK install. If not, you'll

    need to point it in the right direction.

    Creating and Executing a Simple Java Program

    ? In JCreator, start a new project from the File menu. It should bring up a window that looks similar

    to this. You must give the project a name. Note where the program is storing your project if you

    need to do anything with these files later, you will need to know how to get to them.

? Click the “Finish” button, and you should have a new project that looks something like this:

? In the File view in the upper left of the window, note the “src” folder. This folder contains all of

    your source code (whether in a single file or multiple files). Other parts of this screen will make

    sense as we progress through the course. For now, though, expand the “src” folder, and double

    click on HelloWorld.java. It should open up a file that has been filled out for you. Replace the

    code in the main() method with the following code:

    System.out.println(“Hello World!”);

    ? In the Build menu, choose “Compile Project”. This will run the javac compiler against all of the

    source code you have associated with this project.

    ? If the compile step is successfule, return to the same Build menu and select Execute Project. A

    command line prompt should pop up and you should see the same output as before.

Report this document

For any questions or suggestions please email
cust-service@docsford.com