Monday, March 25, 2013

Java;Notes - 4.) Java Command Line Basics: Moving in the mess!


Understanding the use of the command line utilities for Java is a needed skill at this point in the game since you might not have a GUI all the time.

So in order to compile and run Java files you simply do the following:
  1. Open the Windows Start Menu
  2. Go to the search bar and type "cmd" into it.
  3. Click the program that comes up. You will get greeted with a Classic Command Line Interface or "CLI"
  4. Now to navigate the file system you simply use the "cd" command which means "Change Directory"
  5. So to get to your Java files you simply use: cd c:\\path\to\java_files (cd C:\Program Files\Java\jdk1.7.0_17 - to get the JDK folder)
  6. To compile a program navigate to where you keep your java programs (cd C:\Users\Zilvarael\Desktop\Android Dev Tools\eclipse\CoffeeShop -- for me)
  7. then you simply use the: javac programName.java (Ex: javac hello.java) javac = Java compiler.
  8. To run the program you simply do the following: java hello to launch any java class file!
To launch a java applet:
  1. Use java compiler on what the applet file: javac applet.java
  2. Launch the applet by using: appletviewer applet.html -- This is after an applet is made in my case I learned from the books example applet (Which can be found in the CoreJava Source we downloaded before.

No comments:

Post a Comment