# A-level Computing/AQA/Java

Java is currently one of the most popular languages in Computing worldwide. It was created to meet the need of the Internet age, with programs that could run on any computer architecture (type of hardware-processor combination) without the need for the programmer to separately compile the code for each architecture. Java was developed by Sun Microsystems, now acquired by, and merged into, Oracle Corporation. Java is open source under the GNU Public License, and its standards are controlled by a community process. There is an independent version of Java called the OpenJDK Runtime Environment (IcedTea6 1.9.10). This has been gaining ground since Oracle took over Sun but it uses the same API (Application Programming Interface). There is a widely recognised set of library functions for Java that are available on-line for free.
Oracle produce versions of Java for Windows, Mac and Linux that are free to download and use. These include three major flavours:
* the Standard Edition comes with libraries for writing client (desktop computer) software, not unlike the standard libraries of many other programming languages. The Standard Edition is the one commonly used for learning Java.
* the Enterprise Edition extends the Standard Edition by adding powerful libraries and tools for writing sophisticated web server applications. Most professional Java developers actually use the Java EE, which is why you will see numerous references to it on Oracle's Java web site and download pages.
* the Micro Edition can be installed alongside the Standard Edition to give access to the cut down libraries used on many mobile phones. The Java ME is rather long in the tooth, and most Java mobile developers have shifted focus to Google's Android (which also uses Java).
There are at least three excellent and free IDEs (Integrated Development environments) for Java. viz BlueJ, Eclipse and NetBeans.
If you are starting out then the author of this page would strongly advise that you initially compile and run a few programs with the command line and then start with BlueJ, advantages being:
* BlueJ does not add extra code to what you have written on compilations. A common theme with sophisticated IDEs that many users find that very confusing when they start out.
* it is very well supported by a couple of Universities.
* there is a huge tutorial site with examples maintained by Oracle.

## Java Myths

* Java is slower than C++. This was true when Java started out but for many years the JRE has used a "Hotspot" compiler which compiles all the frequent areas of code into machine code for the host architecture. You would be hard put to see a difference in all but special cases designed to show off C++
* Java is for the web. No Java is not for the web, it just happens that you can easily write Java Applets for the web. Since Java is not Architecture dependent it will run on any platform for which there is a JRE and within most web browsers. In other words nearly everywhere.
* Java is related to JavaScript. No - JavaScript was a web scripting language written by the Netscape people and they called it Javascript to tag on to the coat tails of the Java Brand.

## Why Java?

* Users of many platforms can download free-of-charge Java compilers, libraries and runtime environments, so students can easily pursue their interest at home, work or at a computer club.
* Java has static typing, also known as strong typing, recommended by some computer scientists to enforce contracts between modules at compile time.
* As of 2012, Java is the standard application language for Android phones and tablets, and one of the two main languages that Google offers, alongside Python, for its customer APIs.

## Why not Java?

* The syntax for Java is probably more difficult for beginners than VB or Pascal.
* Writing simple programs can take a lot more typing than python or VB equivalents

## Getting Started

To get going you need to install a Java SDK (Software Development Kit): the most popular is the Oracle JDK. You probably already have the JRE (Java Runtime Environment). If you haven't, you get one with the JDK anyway.
There are various versions of the JDK. The Standard Edition (Java SE) gives you everything you need to compile programs to run on your own computer, as well as database support. As of version 6, the Java SE SDK come with Java DB (aka Apache Derby), a lightweight embedded database originally developed by IBM.
To get access to something like a mysql database you will need the EE version of the SDK (Enterprise version) and the mysql database connector.

### SDK

* The Oracle Java SDK PC/Linux/Mac
* Users of Linux and Unix may find a version of the Oracle JDK or the IcedTea6 SDK in their distribution's official source repository. IcedTea6 is designed to be compatible with Oracle's JDK 6 and the Java 1.6 published standards.

### IDEs

* BlueJ PC/Linux/Mac
* Eclipse PC/Linux/Mac (use the drop down to select)
* netbeans PC/Linux/Mac (use the drop down to select)
* IntelliJ IDEA − the open source Community edition supports Standard Edition.

### Portable

Portableapps maintain a version of eclipse that can be used from a memory stick on any windows machine

## COMP4

Java is the main language used for developing android applications. You can download a plugin for the Eclipse IDE and there are many free resources out there to get you started.

## Online resources

* Java programming language
Java Programming and other Java books at Wikibooks are listed under Java programming language.

## Books

Useful printed books are as follows:
| Title | ISBN | Suitable for |
| Sams Teach Yourself Java in 24 Hours (covering Java 7 and Android) | 978-0672335754 | |
Android Books:
| Title | ISBN | Suitable for |
| Sams Teach Yourself Android Application Development in 24 Hours | 978-0321673350 | Simple android development |
| Hello, Android: Introducing Google's Mobile Development Platform | 978-1934356562 | Simple android development |

## Notes

* ↑ In Fedora, sudo yum install java-1.6.0-openjdk. See also /usr/share/doc/system-switch-java-1.1.5/README in the system-switch-java package. In Ubuntu sudo aptitude install default-jdk,
* ↑ The proprietary commercial Ultimate edition supports Enterprise Edition and includes scripts to automate refactoring.