Reference no: EM132235732
Installing, Compiling Java
With your coding experience now from both codingame.com and your ZyBook e-text, it is high time you compiled some Java programs from scratch in the Command window (cmd.exe -- WIN) or the Terminal (CTRL-ALT-T -- Unix).
To do so, you may need to download a Java compiler (SDK) to your computer of choice (it is possible this is already installed on the HS104 lab-machines on the Linux-side!).
Homework Instructions:
Type in, compile, and run the Java programs in sections 1 and 2 below.
For each numbered section (> 0):
Paste your final code into your report (this should be identical to the code below; no changes required!)
Take a screenshot of the results of the section's code and paste into your report, along with a paragraph explaining what the code does, and/or why the results came out as they did.
(General install instructions are included below in section 0, if needed!)
Save a copy of your final report in the course TurnIn folder. Turn in a hard-copy of your report in-class on the due-date.
Sections:
0. Java Installation and Program Compile instructions (for WIN)
(Hint: try 0B below first; if javac command not recognized, then do 0A)
A. Install Java SDK
Download the current Java SDK (Software Development Kit) to your machine
Search "download Java JDK" on Google
Find Oracle JDK download section
- (my file was: jdk-8u121-windows-i586.exe)
Note address of default installation directory on your machine
- (e.g. C:\Program Files (x86)\Java\jdk1.8.0_121\)
New binaries directory on your machine:
- C:\Program Files (x86)\Java\jdk1.8.0_121\bin
- Contains javac.exe and java.exe
Verify/Update your system PATH variable with javac.exe's directory
Control Panel: System >> Advanced >> Environment Variables >> PATH >> Edit
- WIN7 and before had semicolon-separated directory-addrs (;) -- with last directory not scolon-terminated!
- WIN10 has a friendlier implementation
B. Compile
? Type and Save a Java class (e.g. #1 below) into a textflie with a .java extension
? Run cmd.exe
? Navigate to your java-file directory (using: cd, dir as needed)
? Compile {fname}.java files to {fname}.class with:
javac {fname}.java
? Run {fname}.class files with:
java {fname}
1. Hello World!
Type and run the following Java program in a single .java-extension textfile (e.g. hello.java):
2. Inheritance Example
Type the following four classes into four individual files.
Attachment:- Compiling your own Java files.rar