Following program describes, it will show ‘First Java Program’ text on screen when user start it. Type the following java code description into your text editor. (Note: Numbers in the gray column are line numbers and it s just for easy reading. Do not type those things in your file!)
Save file into a directory (folder) using file name “First.java” (ex.: C:\MyJava\First.java)
Start Run application by pressing ‘CTRL’ key and ‘R’ key together. Type ‘CMD’ and press enter
to Start Command Prompt or DOS prompt.
Now you are going to start Java. Java software has no any graphical user interface as in Visual Basic. So, you can’t start Java using Windows Start Menu.
Follow the figure while reading this part and also take a look at DOS help at the end of this chapter.
To start java type ‘PATH
Now you want to move Command Prompt to location where you save “First.java”. Type ‘CD
Tip: You may use ‘CD\’ command to jump into root of C: drive because according to this example our .java file is in ‘C:\MyJava’ folder.
Now you have to say, “Create my program please!’ Try this! ‘JAVAC First.java’
To Run Your Program Type ‘JAVA First’ and press enter (Be careful: Java is
Case Sensitive).
You must see ‘First Java Program’ appeared on screen.
If you get some errors, please check your code again. Look for missing semicolons and spellings, letter cases etc… Then check your “PATH” command is OK (Can you find bin folder of java manually?). Finally check you are at the right location to compile your code (In this example; I saved my code in C:\MyJava. You can see that Command prompt; prompt it at the last line).
That’s all! You will repeat this process every time you write a Java program. Lets See How to develop it into real windowed program from next chapter!
No comments:
Post a Comment