Introduction to Java
So you want to learn Java? You may already know another language such as Javascript or PHP and you want to move on to something more complex and powerful, or you may have heard about Java and are curious about it, or one of many other reasons. Whatever your reason(s) may be, Java is a great language to learn!
The word 'Java' has various meanings. It is the name of a programming language, a slang term for coffee, and the name of an island. For the sake of staying on topic, we will be discussing Java the programming language.
Java was invented by Sun Microsystems.
This lesson focuses on:
- What you should already know
- What is Java?
- Java file extensions
- Java and Javascript
- What can be done with Java?
What you should already know
Before studying Java, you should already have at least a basic understanding of a dynamic programming language. This can be a scripting language such as PHP or Javascript or a software application language such as C or C++. If you need to study some language(s) before learning Java, you can do so at our Javascript section or our PHP section.
What is Java?
Java is a programming language used to develop software applications as well as applets that run on webpages.
-
Java is a high level language
Java's syntax allows for the use of words and commands instead of just symbols and numbers, it is closer to human languages and further from machine language. The advantage to Java being a high level language is that it is easier to read, write, and maintain.
-
Java is an object oriented language
With Java, you can define your own reusable data structures called objects as well as define their attributes (properties) and things they can do(methods). You can also create relationships between various objects and data structures.
-
Java is a web language AND a software development language
With Java, you can create applets - small programs that run on webpages, as well as stand-alone software applications.
-
Java is platform independent
You can run the same Java programs on various operating systems without having to rewrite or recompile them, unlike other high level languages such as C and C++. Java is independent of specific hardware architecture and operating systems.
What makes Java's platform independence possible is the way operating systems interpret Java. Java source code will remain the same irregardless of what operating system you are writing a Java program for. Essentialy, Java source code is not converted into machine language, but rather into a special form of instruction known as Java byte code. Java byte code is then interpreted by the Java run-time environment. The Java run-time environment is a Java interpreter which is also known as the Java virtual machine. The Java run-time environment interprets Java byte code and instructs the operating system what to do. This allows for Java's platform independence, since Java source code will be interpreted the same way on all operating systems by the Java run-time environment.
Java and Javascript
Java, Javascript, what's the difference? A major difference!!
There exists a common misconception that Java and Javascript are the same language. They are not. Java is a language used to create applets that run in webpages, as well as stand-alone software applications, while Javascript is a scripting language used to create dynamic and interactive content on webpages.
Java file extensions
Java source code files have a .java extension. Java source code files that have been compiled have a .class extension.
What can be done with Java?
There is alot you can do with Java:
-
Interact with the user
Interact with the user. For example, you can ask the user for their name and print a custom message with it such as "Hello Roger!"
-
Create graphical programs
With Java, you can create graphical programs which can include various graphical components including buttons, textboxes, menus, checkboxes, and more. For example, you can create a simple text editing program such as Window's Notepad.
-
Create applets
An applet is a program that runs within another program. With Java, you can create applets that will run inside webpages. For example, you can create an applet that will get input from the user and store the data in a database.
-
Read from and write to files
You can read from and write to files. For example, you can store data that is input by the user in a text file and retrieve that data when the user accesses the program again.
-
Communicate with databases
Read data stored in a database or write new data to a database. For example, you can store a users name and e-mail address in a database, and allow them to retrieve this information and view it or change it, and the change will be reflected in the database.
All this and more can be done with Java!




