OnlineKnowledgeRepository
OnlineKnowledgeRepository
OnlineKnowledgeRepository
Would you like to react to this message? Create an account in a few clicks or log in to continue.


For Questions and Assistance please use the proper Category.. please..
 
HomeLatest imagesSearchRegisterLog 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
How to Compile and Run Java Programs EmptyThu Sep 01, 2016 7:57 pm by neuron

» Abia State Polytechnic Admission form for 2013/2014 out!
How to Compile and Run Java Programs EmptyTue Oct 08, 2013 9:30 am by stevejoo

» Convert ZD to SIGNED PD
How to Compile and Run Java Programs EmptySun Sep 08, 2013 9:22 pm by neuron

» How to Speed Up My PC
How to Compile and Run Java Programs EmptyTue Feb 26, 2013 9:15 am by alphysudaria143

» Hi I'm alphysudaria143
How to Compile and Run Java Programs EmptySun Feb 17, 2013 12:25 am by alphysudaria143

» How to Copy all the Generations of a GDG
How to Compile and Run Java Programs EmptyThu Oct 11, 2012 8:30 am by neuron

» Remove Duplicates in a dataset though Sort
How to Compile and Run Java Programs EmptyThu Oct 11, 2012 8:23 am by neuron

» how to insert data into your access database vb.net
How to Compile and Run Java Programs EmptyTue Aug 14, 2012 9:56 am by neuron

» how to populate combobox in vb.net during form load
How to Compile and Run Java Programs EmptyTue Aug 14, 2012 9:53 am by neuron

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
Help
Please support me my registering to NEOBUX
advertisements
How to Compile and Run Java Programs Banner3
Affiliates
free forum
 



 

 How to Compile and Run Java Programs

Go down 
AuthorMessage
proton
Great Spammers
Great Spammers
proton


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

How to Compile and Run Java Programs Empty
PostSubject: How to Compile and Run Java Programs   How to Compile and Run Java Programs EmptySun 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.

How to Compile and Run Java Programs 1


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]

How to Compile and Run Java Programs 2

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]

How to Compile and Run Java Programs 4



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 -> https://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..
Back to top Go down
http://computer-learning.isgreat.org
 
How to Compile and Run Java Programs
Back to top 
Page 1 of 1
 Similar topics
-
» Converting Binary to String In Java

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