Running a Java program, JavaDemo.java
- Make a directory for Java. mkdir Java
- Make a directory for each Java program (this keeps them organized)
mkdir JavaDemo
- Create the file for JavaDemo.java (same name as the class)
vi JavaDemo.java
- To compile the file: javac JavaDemo.java (this creates JavaDemo.class)
- To run the file: java JavaDemo (this runs the JavaDemo.class file)
- Make sure the text file "sampleFile.txt" is in the same directory