Anda di halaman 1dari 8

ESSENTIAL SET-UPS IN RUNNING JAVA PROGRAMS

Objectives: a. b. c. d. e. f. g. Install Java compiler programs. Install Crimson Editor. Learn how to create a working Java folder. Use Crimson Editor as an editor program for java codes. Set up the working Java folder as default folder of all java programs. Create a batch program pathJava.bat as shortcut to java compiler and interpreter. Run a java program Hello.java.

Install Java Compiler and Interpreter and related programs


1. Plug-in your CD or FlashDrive where the installer is located. 2. Double click the installer file.

3. Accept all recommendations set by the installer.

Page 1 of 8

Install Crimson Editor


4. Goto Crimson Editor Installer folder. Double click the installer file. Accept all recommendations of the installer.

Create your own working folder


5. Click Start | My Computer 6. Double click (C:) Local Disk. 7. Right Click anywhere from the white background. 8. Click New | Folder. Type CS132L_W710 9. This is where you will save all your Java programs. 10. You should have a setting just as below:

11. On this case, our working folder is MyJava. Page 2 of 8

Launch the Editor Program


12. Click Start | All Programs | Crimson Editor.

13. Crimson editor program will look like this:

Page 3 of 8

Set up your working Java folder as the default folder


14. Click Tools | Preferences | File. 15. Type in the name of your working folder (on this case we have MyJava) inside the box of Initial working directory (or simply click [] to select MyJava folder). 16. Un-click check box Reload last working files on startup. 17. You should have a set-up just like below:

18. Click OK. 19. Click File | Exit. 20. Re-launch again Crimson Editor for the new settings to take effect. 21. Click Start | All Programs | Crimson Editor. 22. Click File | New. 23. Type in your Java Program.

Save Java program


24. Click File | Save. 25. On the given example our program name is Hello. Type Hello inside the filename text box. 26. Under the Save as type, select Java files (*.java; *.jav). Page 4 of 8

27. Your set-up should look like below:

28. Click Save button.

Create batch file to set path to Java compiler and interpreter


29. Click Start | Search. 30. Type in inside the box javac.exe. Click Search Now. 31. Copy the full path or folder on where the file resides. 32. On this case the compiler is under C:\Program Files\Java\jdk1.6.0_01\bin. 33. Click File | New inside the Crimson Editor program. 34. Type: path C:\Program Files\Java\jdk1.6.0_01\bin 35. Click File | Save. 36. Type in pathJava.bat. Set Save as type to All files (*.*)

Page 5 of 8

37. Your dialog box should look like this:

38. Click the Save button.

Compile Java program


39. Click Tools | MS DOS shell. 40. Go to root directory. Type: cd \ 41. Go to our working directory. Type: cd C:\CS132L_T10-1 42. To display the content of the folders, type: dir 43. Make sure the two recent files created are displayed. 44. Run first the batch file you have just created: pathJava.bat. 45. On the command prompt type: pathJava. Press Enter 46. Your screen will look like this:

Page 6 of 8

47. You set already the path to the Java compiler and interpreter. 48. Compile your program. Type on the command prompt: java Hello.java 49. If no error occurs, your screen will look like this:

50. To check if .class file is created, display all files. Type: dir. Press Enter

Page 7 of 8

Run Java program


51. To run your java program Hello, type: java Hello. Press Enter. 52. Final screen will look like this:

Page 8 of 8

Anda mungkin juga menyukai