Learning Java/Introduction to Java: Difference between revisions

Content deleted Content added
mNo edit summary
Line 1:
== What is Java? ==
'''[[Wikipedia:Java (programming language)|Java]]''' is an objectObject-orientedOriented, cross platform, multi-purpose [[Topic:Computer Programming|programming]] language produced by Sun Microsystems. First released in 1995, it was developed to be a machine independent web technology. It was based on C and C++ syntax to make it easy for programmers from those communities to learn. Since then, it has earned a prominent place in the world of computer programming.
 
Java has many distinct characteristics that have contributed to its popularity:
* '''Platform independence''' - Many languages are compatible with only one platform. Java was specifically designed so that it would run on any computer, regardless if it was running Windows, Linux, Mac, Unix or any of the other operating systems.
* '''Simple and easy to use''' - Java's creators tried to design it so code could be written efficiently and easily.
* '''Multi-functional''' - Java can produce many applications from command-line programs to applets to Swing windows (basically, sophisticated graphical user interfaces).
 
== History of Java ==
See ''[[Wikipedia:Java_%28programming_language%29#History|History of Java]]'' article section at Wikipedia
 
== The Java Platform ==
One thing that distinguished Java from some other languages is its ability to run the same compiled code across multiple operating systems.
 
Line 19:
When the code is run by the user, it is processed by something called the Java Virtual Machine (JVM). The JVM is essentially an interpreter for the bytecode. It goes through the bytecode and runs it. There are different versions of the JVM that are compatible with each OS and can run the same code. There is virtually no difference for the end-user, but this makes it a lot easier for developers.
 
== Installing the Java Development Kit ==
Before installing the Java Development Kit (JDK), you should probably know what it is. It is distributed by Sun. It contains the core libraries and compiler required to develop Java. The JDK should not be confused with the JRE (Java Runtime Environment). The JRE is a JVM for running, as opposed to compiling, Java programs.
 
=== Downloading and Installing ===
To download the JDK, go to http://java.sun.com/javase/downloads/index.jsp. Click on "JDK 6.0 with NetBeans 5.5". Follow the instructions for downloading the JDK installation file. If you are running Windows, simply run the executable file and follow the installation instructions. If you are using UNIX, Solaris or Linux, it might take a little more work.
 
If you are using a Macintosh, the latest available JDK is automatically installed by the operating system. Because Java on the Macintosh is developed and maintained by Apple, in coordination with Sun, the current version on the Macintosh may not be the current version that is available from Sun.
 
=== Note on Editions ===
The JDK comes in three editions.
* Java 2 Standard Edition (J2SE) This is the basic platform for Java. This is the one this course uses.
* Java 2 Enterprise Edition (J2EE) This edition is mainly for developing and running distributed multitier architecture Java applications, based largely on modular software components running on an application server. We will not be covering this version in this course.
* Java 2 Micro Edition (J2ME) This is primarily for developing programs to run on consumer applicances, such as PDAs and cell phones.
 
=== Configuring Variables===
Before writing code, it is recommended that you set the Path variable on your system so you can compile your code more easily.
====For Windows Users====
*From the Control Panel, double click "System"
*For XP and 2000, click on the "Advanced" tab and click on "Environment Variables" For NT, click on the "Environment" tab.
*Select the Path variable and click "Edit"
*Add the path to the bin directory of where Java is installed on your hard drive. It should probably be: C:\Program Files\Java\jdk1.6.0\bin unless you changed it during installation.
*Click OK
 
==== For LinuxWindows andUsers UNIX====
* From the Control Panel, double click "System"
* For XP and 2000, click on the "Advanced" tab and click on "Environment Variables" For NT, click on the "Environment" tab.
* Select the Path variable and click "Edit"
* Add the path to the bin directory of where Java is installed on your hard drive. It should probably be: C:\Program Files\Java\jdk1.6.0\bin unless you changed it during installation.
* Click OK
 
==== For Linux and UNIX ====
One way to set your path in Linux/Unix is to add a path export to your bash profile.
 
* In order to do this, first open your bash profile in a text editor. For example,
<blockquote>pico ~/.bash_profile</blockquote>
* Then add this line:
<blockquote>export PATH=$PATH:/usr/local/jdk/bin</blockquote>
Note that the path to the java directory "/usr/local/jdk/bin" may be different on your machine.
* Restart your shell.
 
==== For Macintosh ====
Apple sets everything up for you. Sit back and relax.
 
Line 59 ⟶ 60:
Oh well, you can't have everything.
 
== "Hello World" ==
Anytime you learn a computer programming language, it is tradition that the first program you write should be to make your computer say, "Hello World". This is a small feat, but is a good opportunity to make sure that you installed the JDK properly.