The two lines of text at the bottom show the set of actions available in the editor. You should see something like the following: Today we'll try nano because it is easy to use for beginners. However, it can sometimes be convenient to edit a file directly in the terminal. Normally, we will be using an Integrated Development Environment (IDE) to edit and compile Java programs. Congratulations! You've successfully compiled and executed your first Java program.Now that Welcome.java has been compiled, it can be executed:.class files are not intended to be read or edited by humans. These are "machine language" instructions written in the language of the Java Virtual Machine. The file Welcome.class contains Java byte code. Examine the contents of Welcome.class using the cat command.ĭon't worry! The contents shouldn't make sense to you.If all goes well, this command should not produce any output to the terminal window, but it should create a new file named Welcome.class.Examine the contents of Welcome.java using the cat command.Confirm that you completed the last two steps correctly by using the pwd command (to confirm that you are in the lab02 directory) and the ls command (to confirm that you successfully copied Welcome.java).Copy the file /cs/shr/cs149/code/Welcome.java into the lab02 directory:Ĭp /cs/shr/cs149/code/Welcome.java Welcome.java.Create a folder inside your home directory named lab02.Create a cs149 folder in your home directory.Refer back to the Unix Tutorial for Beginners if you need to refresh yourself on the necessary commands.
Compiling and Executing Java in the TerminalĮach of the steps below should be completed entirely inside the terminal: no GUI applications allowed. You may work on this lab individually or in a group of no more than three people. The goal for this lab is to gain experience editing, compiling and executing Java programs in the terminal and through the JGrasp IDE. Lab02: Java Comand Line and JGRasp Compiling Java Lab 2A Introduction