OnlineKnowledgeRepository


For Questions and Assistance please use the proper Category.. please..
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Welcome guys!!.. In order for you guys to post your Questions and assistance requests,, please REGISTER first.. Only members can post.. If you have requests then feel free to email ADMIN neuron or SPAMMER onatzky.. thanks!
Search
 
 

Display results as :
 
Rechercher Advanced Search
Donation box
Latest topics
» Convert signed ZD to PD
Thu Sep 01, 2016 7:57 pm by neuron

» Abia State Polytechnic Admission form for 2013/2014 out!
Tue Oct 08, 2013 9:30 am by stevejoo

» Convert ZD to SIGNED PD
Sun Sep 08, 2013 9:22 pm by neuron

» How to Speed Up My PC
Tue Feb 26, 2013 9:15 am by alphysudaria143

» Hi I'm alphysudaria143
Sun Feb 17, 2013 12:25 am by alphysudaria143

» How to Copy all the Generations of a GDG
Thu Oct 11, 2012 8:30 am by neuron

» Remove Duplicates in a dataset though Sort
Thu Oct 11, 2012 8:23 am by neuron

» how to insert data into your access database vb.net
Tue Aug 14, 2012 9:56 am by neuron

» how to populate combobox in vb.net during form load
Tue Aug 14, 2012 9:53 am by neuron

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
Help
Please support me my registering to NEOBUX
advertisements
Affiliates
free forum
 



Share | 
 

 How to Compile and Run Java Programs

View previous topic View next topic Go down 
AuthorMessage
proton
Great Spammers
Great Spammers
avatar

Posts : 14
Join date : 2009-08-06
Location : Tarlac City, Philippines

PostSubject: How to Compile and Run Java Programs   Sun Aug 09, 2009 6:25 am

this is a simple tutorial on how to compile and run java programs, i made this coz i have seen many of beginners doesn't know how to compile and run..

First, we should have JDK installed on our PC.. any version will do as long as it is JDK.. you can download it from http://developers.sun.com/downloads/new.jsp it's free.. after downloading, install it..

now, we have a JDK installed, we can now start to program.

1. Coding the Java Program.. here's a very simple java program. the HELLOWORLD program.. (copy the code below and paste it on a notepad. save it as HelloWorld.java, make sure the classname and the filename must be the same, java is case sensitive. and make sure you saved it as in .java file extension and not in .txt)

Code:

/**
* The HelloWorld class implements an application that
* simply prints \\"Hello World!\\" to standard output.
*/
class HelloWorld {
public static void main(String[] args) {
System.out.println(\\"Hello World!\\"); // Display the string.
}
}



Notice the /**/ -- this is a block comment.. and the
// -- this is a line comment, the characters after // and along the line, will not display..

it's a great help if you put comments on your programs.. you'll not be confused when you are programming a huge java program..


2. Compiling Java Program

- click start >> run >>> type cmd.. then the command prompt should be there.




type in there, "cd C:\\Program Files\\Java\\jdk1.6.0_06\\bin" and press return(without quotes)
where C:\\Program Files\\Java\\jdk1.6.0_06\\bin is the directory path of my bin folder where my JDK is installed..

you will notice that from C:\\Documents and Settings\\onatlheen\\> will
become C:\\Program Files\\Java\\jdk1.6.0_06\\bin\\> [see figure below]



type in "javac C:\\java\\HelloWorld.java" [without quotes] and press return

*where C:\\java is the directory path of my java file.. and HelloWorld.java is the filename that i am compiling.

to know if it was compiled, a .class file with a same filename will create on the same folder where HelloWorld.java resides..

If you do not have the HelloWorld.class file, it was not compiled. repeat steps from the beginning CAREFULLY.. do not proceed on the next step, because you can't.. lol..

3. Running the Java Program

-on the command prompt, type in there "cd C:\\java" [without quotes] and press return

*where C:\\java is the directory path of my java program.
*to know the directory path of your java program, look at the address bar of the folder.

and finally type "java HelloWorld" [without quotes] and press return

you will now see the output of your program! [refer to the figure below]





SUMMARY for the Experienced in command prompt

1. cd [bin folder of the JDK installed]
2. javac [dir path of the file] [filename to compile]
3. cd [dir path of the file]
4. java [filename of java program file]


You may reply to this post through this thread -> http://myonlinekr.forumotion.com/programming-f11/ if you have some questions.. I am not great in creating tutorials.. I'm only great in spamming forum boards..

_________________
[]D [] []\/[] []D
Back to top Go down
View user profile http://computer-learning.isgreat.org
 
How to Compile and Run Java Programs
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Spitzer Cycle 6 programms
» List of GPPB accredited training institutions
» Can a fifth class municipality have two BAC?
» Number 6
» The advisory board recommends passage of the budget programs of donor countries to reform the economy

Permissions in this forum:You cannot reply to topics in this forum
OnlineKnowledgeRepository :: All About PC :: Programming :: JAVA-
Jump to: