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
If you find this forum helpful.. you now have the option to donate through Paypal. Just click the donate button below to transfer you to paypal page.
Latest topics
» Forum has been sent out to FACEBOOK
Sat Jun 26, 2010 8:40 pm by neuron

» Request for IMS sample code
Mon Apr 19, 2010 2:39 pm by light_yagami

» how to execute an exe using vb.net
Mon Jan 04, 2010 4:56 am by neuron

» How to Check and create a folder in VB.NET
Thu Sep 03, 2009 9:08 am by neuron

» USing the File Browser in VB.net
Thu Aug 27, 2009 10:29 pm by neuron

» How to open an access database and populate datagrid view in VB.NET
Sat Aug 22, 2009 11:22 am by neuron

» How to add a dynamic clock in your VB.NET FORM
Sat Aug 22, 2009 1:42 am by neuron

» How to enable screensaver using vb.net
Fri Aug 21, 2009 7:37 pm by neuron

» Hi To all of you guys
Fri Aug 14, 2009 11:43 pm by neuron

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
Forum
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


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

PostSubject: How to Compile and Run Java Programs   Sun Aug 09, 2009 8:25 pm

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

-
» How to write java programs for mobile phones?
» Java Programs isc icse bluej questions for practice
» Java Programs
» Where can I find small java programs to mess around with?
» I need 3 Java programs to be solved asap. Thanx.

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