Writing a Java Program

Contact Us or call 1-877-932-8228
Writing a Java Program

Writing a Java Program

Java source code is written in plain text, using a text editor.

  • This could range from a plain text editor like Notepad, to a programmers' editor such as TextPad, EditPlus, or Crimson Editor, to a complex integrated development environment (IDE) like NetBeans, Eclipse, or JDeveloper.
  • The source code file should have a .java extension.

The javac compiler is then used to compile the source code into bytecode.

javac MyClass.java
  • The bytecode is stored in a file with an extension .class
  • Bytecode is universal - one bytecode file will run on any supported platform.

You then run the java runtime engine, which will then interpret the bytecode to execute the program.

java MyClass
  • The executable program you are running is: java.
  • The class name tells the JVM what class to load and run the main method for.
  • You must have a JVM made specifically for your hardware/OS platform.JVM Diagram
Next