Using the Java JDK and - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Using the Java JDK and

Description:

... following URL to download the compressed file of Java 5.0: ... Java's class names (String, System) are in dark blue. String literals ('Howdy Ags') are magenta ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 21
Provided by: dianer9
Category:
Tags: jdk | java | javas | resized | using

less

Transcript and Presenter's Notes

Title: Using the Java JDK and


1
Using the Java JDK and JCreator as an Editor
Use Java 5.0 Update 8, from Sun Microsystems, as
the compiler Use JCreator 3.50, from Xinox
Software, as the IDE
2
  • First, install Java 5.0 JDK (Java Development
    Kit).
  • Go to the following URL to download the
    compressed file of Java 5.0
  • http//java.sun.com/javase/downloads/index.jsp

3
  • On the next screen, select one of the first two
    JDKs (if you have Windows)
  • Save to Disk, usually to the desktop. Make a note
    of where you saved the zipped file.
  • 3. Double-click to the zipped icon to install
    (and unzip) the application. You must accept the
    license agreement. Follow the prompts, usually
    accepting the default settings.

4
  • Once Java 5.0 is installed, go to the following
    URL to download the compressed file of JCreator
  • http//jcreator.com/download.htm
  • 2. Choose the latest Freeware version -- at the
    time this slide presentation was prepared, it was
    v 3.50.

5
  • You will be asked to give your email address. An
    email will be sent immediately containing the URL
    to use for downloading.
  • Save the zipped file to your desktop.
  • 6. Click on the jcrea350 icon on the desktop to
    install.
  • Save it in the default directory ? c\Program
    Files\Xinox software\JCreatorV3LE
  • Next.
  • Yes, create the folder.
  • Add program to Start Menu folder. Next.
  • Create desktop icon. Next.
  • Install.
  • Finish.

6
  • Open the JCreator IDE (Integrated Development
    Environment).
  • There are four windows. The File View window (1)
    lists files that are currently open. The edit
    window (2) is empty until a program file is
    created or opened. As a beginning programmer you
    will not be using the Package View window (3).
    Window 4 changes with the task at hand. It is
    used for debugging programs. We will see an
    example of this later on.
  • 3. The next slide is a guide to create a new
    file (we will only set up FirstProgram.java but
    actually not type anything into the editor).

7
  • To create a new file
  • Under the file menu, select NewFile.
  • You must name the file first navigate to the
    directory where you are saving your files (click
    on the box indicated by the arrow) example
    c\Java
  • Type in the Name dialogue box FirstProgram
    (JCreator will add the .java extension). Click
    Finish.

8
  • 4. There is now an edit window. The cursor is
    at column 1 on line 1.
  • Notice that the tab at the top of the edit window
    contains the file name. As you create more
    programs, they can be opened and listed in this
    window.
  • 6. The file name is also listed in the File View
    window as well as in the Title Bar of JCreator.
  • 7. If you were actually keying in a program, you
    would start keying at the top of the edit window.

9
  • To open an existing file
  • Under the file menu, select Open.
  • Navigate to the folder containing the existing
    files.
  • Open the Howdy.java program

10
  • The JCreator IDE provides several visual cues
  • Comments are green
  • Keywords (public, class, static, void) are blue
  • Javas class names (String, System) are in dark
    blue
  • String literals (Howdy Ags) are magenta
  • The JCreator IDE provides other editing features
  • Automatic indenting of blocks of code
  • Automatic closing of braces or parentheses
  • Line numbers on left of edit window
  • Drag and drop feature
  • Global find and replace (binoculars on toolbar,
    or under Search menu)
  • Undo option (button on toolbar) can go back
    and undo lots of steps

11
  • To compile and execute the file
  • Under the Build menu are the commands Compile
    file and Execute file. Button shortcuts for
    these commands are on the toolbar, indicated by
    the arrows above. The F5 key is also a shortcut
    for Execute.
  • First, use the Compile button (the blue down
    arrow). If no errors were found, Process
    completed. will appear in the Build Output
    window at the bottom of the editor.
  • Secondly, use the Execute button (the blue right
    arrow). Your output will appear in a DOS
    window. The Press any key to continue message
    will appear on all output. Press any key (or the
    close box) to close the DOS window.

12
Were you successful in compiling your
program? 1. When installing the JCreator IDE,
Java 5.0 should have been located automatically.
However, if JCreator did not locate the jdk, see
either a or b below a. When you compile your
first program, you will get the message to locate
the jdk. It will either be found in c\Program
Files\Java or c\Java. b. An alternative way to
locate the jdk go to the Configure menu,
Options, JDK Profiles and then select where Java
5.0 is installed
Click on New either C\Program
Files\Java or C\Java Click on (or select) jdk
1.5.0_07 OK OK Apply OK
13
  • Lets make some mistakes and debug them
  • In the Howdy.java program, purposely misspell
    static (satic) and omit the semicolon on line 7.

public class Howdy public satic void
main(String args) System.out.println("Ho
wdy Ags")
  • 2. Compile the file.
  • Two errors will appear in the Tasks List window
    at the bottom of the screen. It will tell what
    lines the errors are on. However, the messages
    given in the Build Output window are more
    informative. Click on the Build Output tab.
    Scroll to the top of the window, begin with error
    1 and work through the errors. (See next
    slide.)

14
-----------------Configuration
ltDefaultgt-------------------- C\Java\Howdy.java5
ltidentifiergt expected public satic void
main(String args)
C\Java\Howdy.java9 '' expected 2
errors Process completed.
Whenever errors are reported by the compiler,
look both for the line number listed as well as
the carat indicator (). The carat may point
at the actual error or it may point to the next
token following the error. In the two errors
in this program, the carat points to the token
after the error. The first error is on line 5
the carat appears at the word void. The word
satic is not recognized by Java. The compiler
does not like the use of the keyword void
following that unknown word. In the second error,
the compiler indicates that a semicolon () is
expected on line 9. An attempt to close the
block of code (with ) cannot be done without
first ending (or closing) the statement preceding
it. The semicolon closes the statement on line
8.
15
After correcting these errors, compile again.
Are there other errors? If so, correct them.
When the only message showing up in your Build
Options window is Process completed, the
program is ready to be executed. Important
Points ! ! ! ! ! ! ! ! ! All programmers make
mistakes. ! The mark of a good programmer is
the ability to interpret the error messages
returned by the compiler and make the necessary
corrections. ! The types of errors we are
speaking of at this time are syntax errors. The
compiler will detect syntax errors. ! Run time
errors occur during execution of a program and
cause the program to halt or crash.
Interpreting the error messages takes practice.
! Logic errors are errors that may go
undetected. The program compiles and executes,
however, the output is incorrect. These errors
can be difficult to even find much less correct.
16
  • Tips
  • JCreator automatically indents blocks of code.
    As you put together longer programs and put
    blocks of code inside other blocks of code, a lot
    of horizontal space can be taken up by the
    indentations. To reduce the tab space to 2 or 3
    spaces, go to the Options menu Editor Java.
    Here is also where you can customize colors,
    fonts, etc. Wait to make these kinds of changes
    until after you have used JCreator for a while.

17
  • Tips (continued)
  • 2. If your output appears in the DOS window and
    theres lots of output, it may scroll off the
    screen. In that case you may want to increase
    the size of the DOS window.
  • While the DOS Window is open, click on the C\
    button at the upper left corner, select
    Properties, select the Layout tab, and increase
    the height of the Window Size. OK.
  • It is here that you can customize the color and
    size of the font, etc., in the DOS window.
  • Select the Save properties for future windows

18
  • Tips (continued)
  • If you have closed JCreator and/or exited all of
    your programs, you can see the four most recent
    files you worked on by going to the File Menu and
    selecting Recent Files. Select the files you
    want to continue working on.

19
  • Tips (continued)
  • 4. This last tip is one that hopefully you will
    not need to use. The windows in the JCreator IDE
    can be resized, moved around and even removed.
    In the event that you lose the Build Output
    window, and any attempts to get it back by going
    to the View menu fail, do the following
  • Close JCreator
  • Go to the Start Menu Run type in regedit
    OK.
  • Under My Computer, double click
    HKEY_CURRENT_USER.
  • Double click Software, double click Xinox
    Software, double click JCreatorV3LE
  • Select Settings and delete all of the many
    settings that are inside the folder. You will
    have to delete each one individually!

This does not happen very often but it is really
frustrating when it does.
20
Good luck!
Have fun Java programming in JCreator!
Write a Comment
User Comments (0)
About PowerShow.com