Hello Jules! it seems like you wanna know what those two lines of code does?
javac Zoo.java - used to compile the java class you have written here named Zoo.
java Zoo - used to run the java compiled file to show you the output.
In Netbeans you can see a play button in green in tool bar which will do the work done by these two lines of code!.Else you can right click your mouse anywhere in the blankspace of the Zoo.java terminal you have send the snapshot of and select "run file" option to execute the program.S
Since you have not written any message to be displayed it will show you build succesful which means your program has been executed.
I hope I am able to help you.
Perhaps you could tell us what this guide is? I ask because it seems to be telling you how to compile and run Java code via the command line, but you're using Netbeans instead of the command line. Did it tell you to use Netbeans?
John Joe wrote:
Since you using NetBeans, why don't you run it by clicking the green button ?
I've tried typing it in the command line but it doesn't work.
Does this shows any error ?
Thank you John, it works using the green button, but I asked about the lines because a later exercise uses those commands to pass parameters, and I don't know how to do that in NetBeans (I wrote the example in another comment.)
When I run it in the command line it says '$' is not recognized as an internal or external command.
Paul Clapham wrote:Perhaps you could tell us what this guide is? I ask because it seems to be telling you how to compile and run Java code via the command line, but you're using Netbeans instead of the command line. Did it tell you to use Netbeans?
The guide is Ch. 1, OCA : Oracle Certified Associate Java SE 8 Programmer I: Study Guide Exam 1Z0-808
The course the assigned the reading said to use NetBeans, although the guide itself did not
The book "OCA Oracle Certified Associate Java SE 8 Programmer I: Study Guide" wants you to use the command line in the section of the book you are referring to. An IDE like Netbeans or Eclipse will save you time in coding but it hides the details of the java programming language which you need to get a better understanding.
Steps to run your program in command line
1. Ensure you have installed the JDK, the latest being jdk 1.8.0_121. You will find it here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. The default installed location is usually C:\Program Files\Java but check to be sure. You need to know.
2. In a text editor such as notepad, notepad++, enter the code. Save the file and save the file name as filename.java. Note the location of where this file is saved.
3. Open your command prompt and enter the location of filename.java. So if you saved that file in your Documents directory, then in command prompt simply enter cd C:\Users\yourUserName\Documents and press enter. "cd" means change directory.
4. Set the path of the JDK. So enter the following set path=%path%;C:\Program Files\Java\jdk1.8.0_121\bin and press enter. You should not get any errors.
5.Compile the code by typing: javac filename.java and press enter.
6. Run your code by typing: java filename and press enter. Your output will show.
This link will help: http://www.oracle.com/technetwork/java/compile-136656.html
Nkechi Nnaji wrote: . . . 4. Set the path of the JDK. So enter the following set path=%path%;C:\Program Files\Java\jdk1.8.0_121\bin and press enter. You should not get any errors. . . .
Thank you for all the details, one of the few first posts to earn a cow But I think there is a potential mistake there in No 4: it is better to do this
set path=C:\Program Files\Java\jdk1.8.0_121\bin%path%; because you can get problems if there is an older Java® installation anywhere else in the PATH.