Jump to content

[Guide]Starting Java Using Netbeans


Recommended Posts

1. Brief history and overview:

In the late 70's Bill Joy(vice president of Sun Microsystems), wanted to design a programming language that combines the best features of C and MESA(an old programming language developed by Xerox). Joy as well attempted to re-write the UNIX operating system on C++ years later, but according to him, C++ wasn't the best choice for that specific goal. In January 1991 Bill Joy meets James Gosling, Patrick Naughton, Mike Sheradin in Aspen, Colorado. This was the beginning of the "Stealth project". The idea behind the project was to be simplified the programming of embedded devices plus their business distribution and sales on the market. C++ was considered as too sophisticated and not "flexible" enough. The software gurus behind the "Stealth project" then divided the goals and James Gosling was the person to develop the software for the new business solutions. Others took the business management and so on...Gosling named the new programming language "Oak", "thanks" to an Oak three outside his window. However, later the name "Oak" appeared as patent to other programming language. And Gosling was forced to change it. Then, surprisingly the language was named after a local coffee shop in the neighborhood of Gosling. It was perfect choice,just because the name also combined the initials of the programmers: James gosling, Arthur Van hoff, Andy bechtolsheim. After several years of tests and innovations plus millions invested, the new language appears as Java 1.0. The motto behind the release was: "Write Once, Run Everywhere".



The Java influence nowadays:



The example above (date: 2004, April) shows the extreme popularity of Java. And not only that, but it shows that Java is the MOST POPULAR LANGUAGE. In fact although it's not mentioned in the above diagram, only C has more popularity, but assuming that on the Google searches, most software developers search for C in order to understand languages like C++ or C#, we can be sure that Java is by itself number 1 leader as popularity among the programmers nowadays. And...according to some surveys Java is also the programming language with best future. It is as well the leader when it comes to mobile phone applications, and we know the mobile phones became a top business target for companies like Google and Yahoo. At the end, it would be interesting to be mentioned that Google.com itself uses Java technologies. So, at the moment if you weren't aware of the great popularity, long history and perspective of Java, you are now maybe pretty interested to learn more of the Java language and of course, to learn how can you use this gem. Let's start.



2. Setup your computer to work with Java:

Java is FREE and multiplatform. You can run it on Windows (XP, Vista, and others), Linux, Mac OS, Solaris. However, for the current tutorial we will give a very detailed example how to install Java on Windows, and as well you will find that the installation is relatively similar on other operating systems. On Linux for example you could better use the compiled RPM package for easier installation. Then (on Linux) assuming that you use for example Redhat based distro, just open it with the "software installer" and you will have it installed in a minute. Now, lets see on Windows, what do you need:


2.1 Download Java:

At first sight, the tools needed to program on Java might be confusing for the newbie. But in fact programming on Java is pretty simple. All you need is the Java interpreter(which actually executes the Java programs) and some IDE that transforms the Java code into a program. In simple words, you write your Java code on the Java IDE and then later you test it thanks to the Java interpreter. Just two programs...


2.2 Download and install the Java platform (the interpreter):

Go here and save the dialog that appears: http://javadl.sun.com/webapps/download/AutoDL?BundleId=18713

This is the installer, which is about 15MB.


2.3 Running the Java installer:

Run the installer, chose "Accept":


You should see this:


After the installer finishes, you should see this:


And, this is it! You now have the Java platform installed, which does anything necessary so that you can now launch Java applications on your computer. Now that we have Java installed, lets install and the development environment, so we can create our own Java applications!


2.4 Download JDK + Netbeans(the Java development tools):

Go here:Download Java SE Development Kit 6u5 with NetBeans IDE 6.0.1 Bundle

1. Click on the "download" button.

2. Chose your OS. For this tutorial we use Windows;

3. Accept the Terms and conditions and click "Next".

4. On the next page your download will either start automatically if you use IE, or if you use some other browser you must save the link: jdk-1_5_0_15-nb-6_0_1-windows-ml.exe. This is located below "Required files"...


2.5 Install JDK + Netbeans:

Start the installer, you must see this:


Now you must see screen similar to this, click "Next":


On the next screen accept the "terms and conditions" and click "Next":


Chose installation directory and click "Next":


Select directory to install "Netbeans" and click "Next":


Now click "Install":


Now you must see the installation:


After the installation is over you should see this below...you have option to register "Netbeans" and Java, but I chose not to do, so I won't receive any ad emails...at the end click "Finish":


OK, so now you have the Java interpreter already installed + you have just installed the development environment so that you can now start the real programming! Now, on your Desktop you will have icon named NetBeans IDE 6.0.1. Click twice on it to open it.



3. Your first Java program:

After you open Netbeans you should see screen similar to this one below. Click on the image to see in full size.


Now click on "File -> New project":

Click on the image to see in full size:


Then chose "Java -> "Java application" and click "Next":


Then, name your application as you wish and click "Finish":


Then you should see a screen similar to this:


Now, you can just copy the text below and paste it on a clean screen on the Neatbeans, you can even modify the code here and then paste it on the IDE:

* To change this template, choose Tools | Templates
* and open the template in the editor.

package javaapplicationmyap;

* @author Deus
public class Main {

    * @param args the command line arguments
   public static void main(String[] args) {
       // TODO code application logic here
       System.out.println("Hello World");


Another closer screenshot on the "Hello world" program:




Now click "F6" on the keyboard OR you can chose "Run -> "Run main project":

Click on the image to see the full size:



You should now see this, take a look on the bottom of the Netbeans, the execution of the program showing the string "Hello world".Click on the image to see full size:



Though this program might seem "Easy" to you, it actually shows you many aspects of the OOP programming plus the Java programming itself. Lets explain the program in detail:


On the very top of your application you will spot the pale/gray lines:

* To change this template, choose Tools | Templates
* and open the template in the editor.


In fact these lines are NOT 100% necessary. These are the so called "comments". A comment is just line of explanation written by the programmer to explain to other programmers what the purpose of certain thing in the program is. The compiler actually neglects the comments. But of course, as any part of the programs the comments have own syntax. Note the "/*" signs. Every comment must start either with the /* sign and end with a closing *\ or IF your comment is just on a single line you can use //. These are the so called "C like" comments. Just because the C language was the first one to use such style of comments.


The first line "package javaapplicationmyap;" , simply shows you that everything in your application belongs to a package of classes called " javaapplicationmyap". The word "package" is a keyword, the " javaapplicationmyap" is the package of classes and the ";" is the semicolon identificator which is nothing special but a way to close the current line.


The second line of your first program "public class Main" defines the class.


The third line is the so called "method". For now you can think of the "method" as an obligatory part of any Java program. All Java programs must have the so called Main method which you use here as well...public static void main(String[] args).The word "public" means that this method can be accessed anywhere later in your program. The word "static" means that this method doesn't read any data out of that specific class, the word "void" means that nothing is expected to be returned by the method and "main" is as we mentioned the required method, stating that this is the famous and required "main" method.


And below is the heart of your program. Within the quotation marks you can write ANY sentence you want, just to have some fun with your first program. Such as you can write your name there or the name of your beloved one. It's up to you, but remember Java can DO a lot more than that! As we stated in the very beginning of this tutorial it is used in Google, it is even on Mars, since the Mars tutor is programmed on Java. It is on the mobile phones.


System.out.printIn("Hello world");


Credits Jordan




Link to comment
Share on other sites

Well explained, but..


Eclipse is much better for coding than NetBeans.


thnx! ok eclipse is much better and for me ! but i just want to help ppl that hate eclipse! i know lot of ppl that cant work with eclipse :)

Link to comment
Share on other sites

thnx! ok eclipse is much better and for me ! but i just want to help ppl that hate eclipse! i know lot of ppl that cant work with eclipse :)


Yeap, maybe.


NetBeans has very good GUI Builer (100x times better than Eclipse GUI Builer plugin)


But Eclipse code editor is 101x times better than NetBeans.


- in my opinion of course.

Link to comment
Share on other sites

I must say I nice guide, even though I am already using netbeans and it is great. Eclipse better than netbeans ? I would not say so, I used to use netbeans and it kept hugging all memory and crashing etc. Netbeans has not crashed once for me and does not use as much resources as eclipse did. Also Netbeans has better identions and hints.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Posts

    • Topic locked.
    • Kelly Clarkson Keto Gummies [SCAM WARNING 2023] Is It Worth Buying? Thusly, industry aces profoundly encourage that you lead further concentrate on the item prior to spending any cash in it. One of these choices is to utilize the keto candy known as "Keto Gummies." When you investigate it, you'll observe that there are a wide range of sorts of Kelly Clarkson Keto Gummies; despite the fact that they could all profess to get exactly the same things done, they're not something similar. Along these lines, we'll give you all you really want to be familiar with Kelly Clarkson Keto Gummies at this moment. https://groups.google.com/g/kelly-clarkson-keto-gummies-official/c/1vV0b1zknw8 https://groups.google.com/g/kelly-clarkson-keto-gummies-official/c/i8lbQL7g9mU https://sites.google.com/view/kellyclarksonweightlossgummie/ https://sites.google.com/view/kellyclarkson-weightloss-gummy/ https://infogram.com/kelly-clarkson-weight-loss-gummies-reviews-scam-or-legit-shark-tank-exposed-1hd12yxqxzzox6k https://infogram.com/kelly-clarkson-weight-loss-gummies-review-scam-exposed-shark-tank-and-customer-feedback-1h7k23050ngyv2x https://www.agentpet.com/forum/discussion/general/kelly-clarkson-weight-loss-gummies-review-the-truth-before-buy https://www.toyorigin.com/community/index.php?threads/kelly-clarkson-weight-loss-gummies-scam-alert-review-a-weight-loss-pill-or-waste-of-money.34009/ https://www.agentpet.com/forum/discussion/general/kelly-clarkson-weight-loss-gummies-reviews-warning-scam https://www.sympla.com.br/produtor/kellyclarksonweightlossgummiesbuy https://www.toyorigin.com/community/index.php?threads/kelly-clarkson-weight-loss-gummies-reviews-warning-scam-read-before-buying.34011/ https://www.facebook.com/profile.php?id=100090213336854
    • Should work via game launcher with auto-updates.
    • updated 7/2/2023   AlisaCodeDragon has been returned as L2Client Developer.! PUFA HAS BEEN TRANSFERED FROM GOLD MEMBER to SUPPORT TEAM
  • Topics

  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock