Writing My First Java Program

This section provides a tutorial example on how to write, compile, and execute the first Java program with JDK 1.8.

When JDK is installed on your machine, it provides two commands for you to compile and run Java programs.

Let's try these commands with a very simple Java program.

First use NotePad to enter the following Java program into a file called Hello.java:

class Hello {
   public static void main(String[] a) {
      System.out.println("Hello world!"); 	
   }
}

Then compile this program in a command window with the "javac" command:

C:\herong>"\Program Files\Java\jdk1.8.0_45\bin\javac.exe" Hello.java

To execute the program, use the java command:

C:\herong>"\Program Files\Java\jdk1.8.0_45\bin\java.exe" Hello
Hello world!

Congratulations, you have successfully entered, compiled and executed your first Java program.

Last update: 2015.

Table of Contents

 About This Book

Installing JDK 1.8 on Windows System

 Downloading and Installing JDK 1.8

Writing My First Java Program

 Setting JAVA_HOME Environment Variable

 Installation of Android SDK R24 and Emulator

 Installing Apache Ant 1.9 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 Android 4.0.3 File Systems

 AboutAndroid - Application to Retrieve System Information

 android.app.Activity Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

 Build Process and Package File Content

 Building Your Own Web Browser

 Android Command Line Shell

 Samsung Galaxy Tab 3 Mini Tablet

 USB Debugging Applications on Samsung Tablet

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 Android Phone - LG-P925g

 USB Debugging Applications on LG-P925g Phone

 Outdated Tutorials

 References

 PDF Printing Version