How to Write Your First Program in Java
from wikiHow - The How to Manual That You Can Edit
Just as we humans use different languages to interact with each other, similarly, computers have their own languages through which we can communicate with them. These languages are broadly of two types: High Level and Low Level Languages.
One very popular High Level language is Java, which can be used to write efficient programs for the internet and the world wide web. Java can also be used to write programs for other environments such as consoles and mobile phones, but its popularity is mainly because of its power to generate robust applications for the internet. Today we'll see how to write a small program in Java. When you begin learning a computer programming language, it is customary to write the "hello world" program as your first. This program tells the computer to display the text "Hello World!" on the computer monitor. It's like telling the world that you are the newest member on board the Java bandwagon. So let's get started!
[edit] Steps
- Navigate to www.java.sun.com and download the Java JDK or Java SE, not JRE (Java Runtime Environment). Once its downloaded, install it. Then restart the computer.
- Open the text editor and write the following code:
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World!");
}
} - Save this code as HelloWorld.java. In Windows, make sure you choose the "all files" option from the file type drop down list box, otherwise it will be saved as a text file and not a .java file.
- Click start > run and type command or cmd (try each and see which one works for your operating system).
- From the command prompt, drill down to the folder where you saved the HelloWorld.java file. (type "cd
" you can use tab for auto completion) - Type the following: javac HelloWorld.java and press Enter. You should see that after thinking for a while the computer returns to the command prompt.
- Type "java HelloWorld" (no quotes) and see what happens. You should see the text "Hello World" displayed on the monitor right below where you issued the java HelloWorld command.
- Type the following: javac HelloWorld.java and press Enter. You should see that after thinking for a while the computer returns to the command prompt.
[edit] Things You'll Need
- Java Development Kit (can be downloaded from Sun Microsystems site for free). Note that for different operating systems there are different JDK's (JDK is a set of tools created by Sun to assist programmers with writing software using Java) Once you've downloaded the JDK, run the setup to set up the development environment.
- Text editor -- for Windows, use notepad; for linux you can use VI or emacs
[edit] Tips
- Java is case sensitive. Remember this.
- If you don't have admistrator privelidges on the computer your trying to install the SDK on, start the installer and when it gets to a part of the install where theres a checkbox asking if you want to add the SDK to the environment variables, uncheck it. It should install properly after that. The only downside is that you can't compile java programs by typing javac in cmd prompt, you have to use a program like Eclipse, NetBeans, or JCreator (I prefer Eclipse). So download and install your choice SDK (Software Development Kit). Then it should ask you to specify where your java SDK or Java SE is installed, specify where the program java.exe is, so find that in your C:\Program Files\JDK\jdk\ directory. Then you're ready to go!
[edit] Related wikiHows
- How to Program in Java
- How to Install Java
- How to Install Java on Linux
- How to Install the Java Software Development Kit
[edit] Sources and Citations
Article provided by wikiHow, a wiki how-to manual. Please edit this article and find author credits at the original wikiHow article on How to Write Your First Program in Java. All content on wikiHow can be shared under a Creative Commons license.
So nice your posting.
ReplyDeleteEverything looks good in your posting.
That will be necessary for all. Thanks for your posting.
Bathmate
thanks buddy!
ReplyDeleteIPL 2015 Images
ReplyDeleteIPL 8 Winner Team
IPL 8 Theme Song
IPL 8 Ringtone Download
IPL 2015 Team Squad
IPL 2015 Winnig Team
CSK vs KKR Live score
CSK vs MI Live score
CSK vs DD Live score
CSK vs RR Live score
CSK vs SRH Live score
CSK vs KXIP Live score
CSK vs RCB Live Score
RCB vs KKR Live Score
RCB vs KXIP Live Score
RCB vs MI Live Score
RCB vs RR Live Score
RCB vs DD Live Score
RCB vs SRH Live Score
KKR vs KXIP Live Score
KKR vs MI Live Score
KKR vs DD Live Score
KKR vs DD Live Score
KKR vs RR Live Score
KKR vs SRH Live Score
MI vs KXIP Live Score
MI vs DD Live Score
MI vs RR Live Score
MI vs SRH Live Score
DD vs KXIP Live Score
DD vs SRH Live Score
DD vs RR Live Score
KXIP vs SRH Live Score
SRH vs RR Live Score
RR vs SRH Live Score