Java is a programming language that has been with us for more than 18 years now but is still, in a way, unknown. A few years ago, you mentioned the name of Java applets and applications and reminded of Java platform. Here you will discover a little more about Java about its history and what it does.
Brief History of Java
Java is a programming language created in 1995 for the same name computing environment by Sun Microsystems. It is said that its name came come from Java Coffee, a cafeteria where its programmers often visited and it is reflected in the logo Java in which we can see of steaming cup of coffee.
Its philosophy is WORA (Write Once, Run Anywhere) allows the developers to port their applications to different systems with little effort, although the variety of devices that can run Java applets leads segmentation between Java desktop applications, business applications and mobile phone applications. In 2010, Oracle bought Sun Microsystems, becoming the new owner of Java.
What is Java for?
Like any programming language, Java is used to create applications and processes that run on a variety of devices. The standard version of Java is responsible for several well-known applications like jDownloader, Vuze and Minecraft.
Java applications communicate with Java Virtual Machine, and not the operating system, which allows programmers to ignore the hardware compatibility.
Java applets are not the only small applications that run on web browser, and but also are required to have installed the corresponding Java plugin included in the standard installation of Java. These applets, embedded in webpages, made things impossible for HTML such as using the camcorder, performing complex operations with images, or creating complex chat systems.
Today, however, the add-ons for the browser as Java and Flash are facing an uncertain future with the advent of HTML5. This version of the web standard, already supported in most browsers, is capable of dealing with multimedia, graphics and local storage in a way that is possible only with add-ons.
Mobile Java applications are based on a shortened version of Java, Java ME (Micro Edition), available in different profiles. These applications can work on a large number of compatible terminals. According to figures from Oracle, there are two billion phones compatible with Java. You can still today find great games that are still running for Java, plus applications such as LINE.
Where is Java Used?
If you paid attention during the installation of Java, you will find Java is present in three billion devices.
- In computers, Windows, Mac, Linux and Solaris which are more than one billion according to Oracle.
- Three billion mobile phone
- Routers
- Parking meters
- ATMs
- Credit cards
- EBook Readers
- Televisions
- PlayStation Consoles
- Mobile VOIP
- MRI (Magnetic Resonance Imaging)
- DVD and Blu-Ray Players
Do you need to install Java?
The answer is probably no. As we said before, Java is still used in applications or in the form of applets integrated in webpage, but if you need it, you will know it. That is, generally you will not need to worry about installing Java unless you need to. And, if you need it, the application or website will be in charge of letting you know.
A Java project is an orderly and organized series according to a logic to keep the code in organized folders. A project usually consists of .java files, .class files, and documentation.
.java Files contain the source code (understandable by humans) in a given time can modify with a text editor and usually found in folders named src (source). The .class files contain bytecode (not understandable by humans but by the Java Virtual Machine) and are usually found in folders named bin (binary).
The organization of the files in folders and the presence of additional ones depends on the development environment that you use. In addition, Java introduces an organizational scheme through packages.
To work with Java projects in most environments, including BlueJ, you have them in an accessible recordable media e.g. in a folder on your hard drive. A project on CD or DVD is not valid because the development environment works by recording information in the active project folder. Therefore, a non-writable medium is not suitable. If you want to work with a project contained in a CD OR DVD, you will have to first copy it to your hard disk and then open it to work with it.
Let’s create your first Java project. For this, it is necessary to create first a folder where to store the project that you are creating. Do it on the route that you think is most appropriate. We will use C: / LearnProjectJava. Click on the Project -> New Project menu and look for the folder where we are going to save the project.
Where you put “File name”, you we will write ProjectP1 or any other name that we consider appropriate.
Then on the left side, you we click on New Class where it asks for the name of the class and you write “Example” and press accept. You will see an icon with the name “Example” and cross stripes. That icon represents a class. Now let’s run a little test. Click on the “Compile” button.
When creating the class, you have created a file named Example.java. By clicking on “Compile”, you have transformed the code that contained that file into bytecode and created the file Example.class. But what code have you compiled if we have not written anything? Indeed, you could not compile anything empty. The explanation is that when creating an empty class, BlueJ creates it with a default code, let’s say a very basic example of code that is already compilable. Let’s check what I said about the files: for this you go to the file explorer and you we go to the path where you saved the project.
In this route, you check the files of your project as follows;
- Example.java: Java language source code.
- Example.class: bytecode or machine code for Java Virtual Machine.
- Other files: files created by BlueJ at the moment but you did not notice.
Now click on the icon of the file Example.java and with the right mouse button choose “Open” to see it with a text editor like the notepad. When you open the file you will see the source code. Close the editor and try to repeat the process with the file icon Example.class. The result will be that Windows tells you that it does not know how to open that file, or if it manage to open it, what you see is series of rare characters. This agrees with what I said: the source code is made up of text and you can see and edit it. The bytecode is a type of machine code, so we cannot edit it directly because it is not understandable to you at this stage.
We have already seen that the file Example.java contains a code. That’s the reason you have been able to compile using BlueJ. Return to BlueJ and to access the code that is in the class, you double click on the icon, which will open the window of the editor of BlueJ and you can continue working on it.
For Java examples, keep visiting browsing and visiting this blog and you will find a plenty of the authentic Java examples.