Java compiler tcci computer coaching

Page 1

Java Compiler Tccicomputercoaching.com Java Language The Java language has its own structure, syntax rules, and programming paradigm like any programming language. The Java language's programming paradigm is based on the concept of OOP, which the language's features support. Java Compilation When you write program for the Java platform, you write source code in .java files and then compile them. The compiler checks your code against the language's syntax rules, then writes out byte code in .class files. Byte code is a set of instructions targeted to run on a Java virtual machine (JVM). In adding this level of abstraction, the Java compiler differs from other language compilers, which write out instructions suitable for the CPU chipset the program will run on. Public class MyFirstJavaProgram { /* this is my first java program. * This will print 'Hello World' as the output */ Public static void main (String [] args) { System.out.println ("Hello World"); // prints Hello World } } Let's Folow these steps how to save the file, compile and run the program.    

Open notepad and add the code as above. Save the file as: MyFirstJavaProgram.java. Open a command prompt window and go to the directory where you saved the class. Assume its C:\. Type ' javac MyFirstJavaProgram.java' and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption: The path variable is set). Now, type ' java MyFirstJavaProgram ' to run your program.

You will be able to see ' Hello World ' printed on the window. C :\>javac MyFirstJavaProgram.java


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Java compiler tcci computer coaching by Rosario Riley - Issuu