Download Installing Java

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 Java
The Oracle Technology Network (OTN) web site is probably the best source of
information for Java:
http://www.oracle.com/technetwork/java/index.html
• Download Java from OTN.
• Java is installed in Linux and Windows in the Computer Science classroom and lab.
• The JDK, Java Development Kit, includes the JRE, Java Runtime Environment.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Windows: (*)
OS X:
Linux:
jre-8u121-windows-i586.exe
// 32-bit ~54 MB
jre-8u121-windows-x64.exe
// 64-bit ~61 MB
jdk-8u121-windows-x64.exe
// 64-bit ~196 MB
Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion
https://support.apple.com/kb/dl1572?locale=en_US
// Java 6
jre-8u121-macosx-x64.dmg
// 64-bit ~62 MB
jdk-8u121-macosx-x64.dmg
// 64-bit ~223 MB
install OpenJDK packages
java-1.8.0-openjdk*
(*) Any standard edition jdk 1.8 update version should work.
OTN has installation documentation on their web site:
http://www.oracle.com/technetwork/java/javase/index-137561.html
Other useful links:
Java SE Documentation at a Glance
http://www.oracle.com/technetwork/java/javase/documentation/index.html
The Java Tutorials
http://docs.oracle.com/javase/tutorial/
Windows Install
The installation instructions described here are for Windows 10 (build 1607) Enterprise
64-bit. There may be some minor adjustments needed for other versions of Windows.
New system variables must be added in order to use the Java JDK. If the new System
variable is not added before installation the JRE might not install properly.
•
•
•
•
•
Right-click on This PC
Select Properties
Select “Advanced system settings”
Click on “Environment Variables…”
Add the following “New…” System variable information:
o Variable name: CLASSPATH
o Variable value: .
o Variable name: JAVA_HOME
o Variable value: C:\Program Files\Java\jdk1.8.0_121 (*)
• “Edit…” the following existing System variable information:
o Variable name: Path
• “New”
o %JAVA_HOME%\bin
// Move Up (Top)
• Click OK three times to accept the path addition and close the dialog boxes.
(*) It is recommended that the modifications shown (bolded) are used.
Double-click on the downloaded file: jre-8u121-windows-i586.exe
Double-click on the downloaded file: jre-8u121-windows-x64.exe
Double-click on the downloaded file: jdk-8u121-windows-x64.exe
Accept all of the default installation options in both cases.
(*) This is only needed if installing the 64-bit version of the Java JDK
• Provides 32-bit support for 32-bit web browsers.
When installation is done the Control Panel will indicate that three new programs have
been installed:
Java 8 Update 121
Java 8 Update 121 (64-bit)
Java SE Development Kit 8 Update 121 (64-bit)
• Start
• Control Panel
• Programs and Features
Confirming the Java Install
Type “java –version” from the command prompt to see the currently installed java
version. Check the system paths and/or system environment variables if incorrect.
Mac OS X 10.11.6 (El Capitan):
Windows 10 (1607 build):
CentOS 6.8 Linux:
Compiling Java Programs
Your Java program source file will have the following naming convention:
<SourceProgramFilename> . java
Each Java file has at least one class in it. The name of the primary class is also the name
of the program file.
Ex:
Java program source filename:
MyFirstJavaProgram.java
public class MyFirstJavaProgram {
public static void main ( String [ ] args ) {
System.out.println ( “My First Java Program” );
}
}
Both Java and Linux are case sensitive so make sure that the source program filename
and the class name are spelled exactly the same.
Java’s portability is achieved by using bytecode and an interpreter. Bytecode is produced
when a Java program is compiled.
Java Source Program
javac MyFirstJavaProgram.java
Java Bytecode
MyFirstJavaProgram.class
Java bytecode then executes under the control of an interpreter designed specifically for
each type of computing platform. This interpreter is called the Java Virtual Machine
(JVM). The combination of the bytecode and a JVM means that you can write a Java
program without knowing what type of computing platform it will be used on.
To run the Java bytecode from the command prompt type
java MyFirstJavaProgram
// the .class extension is not needed
Even though Windows is not case sensitive, the JVM will generate an error if you do not
spell the .class filename with the proper case.
java myfirstjavaprogram
// JVM will not execute the program
Related documents