Download Installing Java SDK on Your System

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Installing the Java JDK on Your System
1. Uninstall any prior version of the Java JDK. Use the Microsoft Windows Add/Remove Programs utility,
accessible from the Control Panel.
2. Download the Java Development Kit 6.0 by going to the web site
http://java.sun.com/javase/downloads/index.jsp or getting it from the CD.
3. Java is installed in C:\Program Files\Java. Open this folder and note the name of the folder starting with
jdk. It might look like jdk1.6.0_13.
4. Change your path variable so that you can conveniently run the JDK executables (javac.exe and
java.exe, etc) from any directory without having to type the full path of the command. In Microsoft
Windows 2000, and XP the path variable can be changed by doing the following:
a. Choose Start, Settings, Control Panel, and double-click on System. Select the Advanced tab
and then click on the Environment Variables button that is close to the bottom of the window.
Look for “Path” in the System Variables. You should see the window that appears below.
b. Click on the Edit… button and you will see the dialog box below. Move your cursor to the end of
the path variable value and type the following (note the file name that is used is the one from 3
above.
;C:\Program Files\Java\jdk1.6.0_13\bin
c.
The new path takes effect in each new Command Prompt window you open after setting the
PATH variable.
8.5 For Windows Vista, to change the path variable, do the following:
a. Start the Control Panel.
b. Type “system path” in the Search box
c. Click on “Edit the system environment variables
d. Click on the Advanced tab
e. From this point the instructions are the same as 8a, b, c above
Homework 1. Creating Your First Application
Your first program, HelloWorldApp, will simply display the greeting "Your Name says Hello world!" followed by a
second line containing “I love my xxx class” where Your Name is stored in a String variable that contains your
actual name and xxx is a class that you like and it is also stored in a string variable. To create this program, you
will:



1.
Create a source file. A source file contains text, written in the Java programming language, that
you and other programmers can understand. You can use any text editor to create and edit
source files.
Compile the source file into a bytecode file. The compiler, javac, takes your source file and
translates its text into instructions that the Java Virtual Machine (Java VM) can understand. The
compiler converts these instructions into a bytecode file.
Run the program contained in the bytecode file. The Java interpreter installed on your computer
implements the Java VM. This interpreter takes your bytecode file and carries out the instructions
by translating them into instructions that your computer can understand.
Start NotePad. In a new document, type in the following code:
/**
* The HelloWorldApp class implements an application that
* displays "Hello World!" to the standard output.
*/
public class HelloWorldApp
{
public static void main(String[] args)
{
// Display my name then "Hello World!"
System.out.println("Your Name Hello World!");
}
}
Save this code to a file. From the menu bar, select File  Save As. In the Save As dialog box:
o Using the Save in drop-down menu, specify the folder (directory) where you'll save your file.
o In the File name text box, type "HelloWorldApp.java", including the double quotation marks.
o From the Save as type drop-down menu, choose All Files. See below for what the Save As
window will look like.
Compile the Source File.
From the Start menu, select the Command Prompt application on the Start button for Windows Vista or for
Windows 2000/XP/NT by going to All Programs -> Accessories -> Command Prompt. When the application
launches, it should look similar to this:
The prompt shows your current directory. To compile your source code file, change your current directory to the
directory where your file is located. For example, if your source directory is java on the C drive, you would type
the following command at the prompt and press Enter:
cd c:\java
Now the prompt should change to C:\java>. If you enter dir at the prompt, you should see your file.
Now you can compile. At the prompt, type the following command and press Enter:
javac HelloWorldApp.java
If your prompt reappears without error messages, congratulations. You have successfully compiled your program.
The compiler has generated a Java bytecode file, HelloWorldApp.class. At the prompt, type dir to see the new
file that was generated:
Now that you have a .class file, you can run your program.
Run the Program.
In the same directory, enter at the prompt:
java HelloWorldApp
Now you should see:
Congratulations!!! You have successfully typed in and executed your first Java program.
Upload your HelloWorldApp.java file for grading by doing the following:





Go to D2L (htpp://elearn.mtsu.edu ). Login with your pipeline username and password.
Click on Dropbox and then on HomeWork1.
Click on Browse under the Submit Files section and then select your file HelloWorldApp.java.
Then click Submit.
You should receive a confirmation e-mail under D2L that indicates that your submission was received.