This tutorial is an introduction to object oriented programming in the high-level computer programming language, Java, on a Mac OS X operating system. The following instructions will guide you through writing, compiling, and executing a simple computer program that prints “Hello World!” to your console.This tutorial will introduce new programmers to basic java syntax. A computer running on a Mac OS X operating system is required. You will be using a text editor and java compiler included on your computer.
No additional software is needed. First you must configure the text editor for java code. On the menu bar on the top left corner of your screen, click on TextEdit, then Preferences.
In the New Document tab, change the document format to Plain Text under the Format section. Uncheck the Smart quotes box under the Options section towards the bottom of the preference window. Switch to the Open and Save tab. Change the Opening files and Saving files to Unicode (UTF-8).
Close the TextEdit application and re-open it. Open a new document. The final step in writing your code is to define the main function in you HelloWorld class. The instructions inside the brackets of the main function will tell your computer what to do when it executes the program. For this program, you want the computer to print the words 'Hello World!' To your console. The java instruction System.out.println( parameter ) will print the parameter of the instruction to the computer console.
Inside the braces of the main function in the HelloWorld class, write the instruction System.out.println('Hello World!' ); Be sure the words that you want the program to print to your console are placed inside quotation marks. Place a semi-colon at the end of your instruction to show that the instruction on that line of code has ended. This step concludes the coding portion of the tutorial.
After using a text editor, such as NotePad, to create your Java program, save the program with a.java extension. Of course, the file name can be anything. For the purposes of this tutorial, 'filename' will be used as a placeholder for your file name.
Your program should look similar to the program in the image above. The indentations are not necessary for the functionality of your program, but they are recommended to make you code more readable. Next, compile your program using the java compiler included on Mac OS X operating systems. You can compile your computer program using your terminal.Your terminal is a device that allows you to communicate with your computer. To open your terminal, click on Finder, Applications, Utilities, then click Terminal. In your terminal, navigate to your HelloWorld.java file.To navigate to your file, you can change directories on your terminal to your desktop where you saved you HelloWorld file.
Use instruction cd (short for Change Directory) to navigate to your desktop. In your terminal, type cd Desktop and press Enter. You can now compile your HelloWorld program. Compiling your program will convert the code in you HelloWord java file to language the computer can read.
To compile your program, type javac HelloWorld.java into your terminal and press Enter. This will create an additional executable file on your desktop that your computer can run. If there are any errors in your code, the compiler will point them out to you on your terminal.
VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVDs, Audio CDs, VCDs, and various streaming protocols. VLC is an open source product developed by VideoLAN Project licensed under GNU GPL v2. Best video player mac os.
- среда 02 января