Download presentation
Presentation is loading. Please wait.
Published byBathsheba Warner Modified over 9 years ago
2
C OMP 110/401 A PPENDIX : I NSTALLING AND U SING B ARE B ONES D EVELOPMENT E NVIRONMENT ON U NIX Instructor: Prasun Dewan (FB 150, dewan@unc.edu)
3
2 I NSTALL L ATEST JDK AND JRE Look at JDK Documentation on how to install it
4
3 C REATE F OLDER FOR A LL J AVA P ROJECTS Y OU C REATE You can create this folder in any existing folder on your computer A folder is another word for a directory You do not have to use the command line to create folder The command line command to create folder is: mkdir (mkdir Java)
5
4 I N J AVA F OLDER C REATE P ROJECT F OLDER FOR T HIS W ARMUP E XERCISE
6
5 I N P ROJECT F OLDER C REATE P ROJECT -S OURCE ( SRC ) AND P ROJECT -B INARY ( BIN ) F OLDERS
7
6 I N S OURCE F OLDER C REATE S OURCE -P ACKAGE F OLDER
8
7 U SE C OMMAND I NTERPRETER TO CD TO S OURCE P ACKAGE FOLDER See command Interpreter documentation on CD and Pasting Text such as Folder Names in Command Interpreter
9
8 U SE A T EXT E DITOR TO C REATE N EW S OURCE J AVA F ILE
10
9 C OPY AND P ASTE C ODE IN T EXT E DITOR AND S AVE F ILE package warmup; import java.io.BufferedReader; import java.io.InputStreamReader; public class AGreeter { static BufferedReader inputStream = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) { System.out.println("Hello World"); if (args.length > 0) { System.out.println(args[0]); } try { System.out.println (inputStream.readLine()); } catch (Exception e) { System.out.println("Could not read line"); e.printStackTrace(); } Package folder name Source file without.java If you use vi, execute i when it opens to get into insert mode, copy and paste the code, then hit escape to get out of insert mode, and then :wq to write and quit the editor
11
10 C OMPILE S OURCE F ILE JDK Binary Folder followed by /javac Source file name Project-binary folder Directory (folder) option See Command Interpreter documentation on how to set PATH if you will use the barebones environment again Do not omit the space between bin and AGreeter.java The JDK binary folder name will be different on your computer
12
11 E XPLORE P ACKAGE B INARY F OLDER Automatically created binary package folder Automatically crated Binary-file If you do not see the binary package folder or the binary file, and no errors were reported, check that you saved the source file (by say reopening it)
13
12 C D TO P ROJECT B INARY F OLDER AND R UN J AVA I NTERPRETER WITH F ULL C LASS N AME Output Full class name If you see the message saying the Java command was not found, then execute it the same way as you did javac – using the full file name with the JDK binary folder – and just replace javac with java in the full name you used
14
13 I NPUT A L INE Input
15
14 H IT E NTER AND S EE O UTPUT Echoed Input
16
15 P ROVIDING U SER A RGUMENT User argument in quotes
17
16 S EEING E CHOED A RGUMENT Echoed user argument
18
17 HIT CTRL-C TO T ERMINATE P ROGRAM W AITING FOR U SER I NPUT Terminated program
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.