kids encyclopedia robot

Java (programming language) facts for kids

Kids Encyclopedia Facts

Java is a popular programming language that helps computers do many different things. It was first made by a company called Sun Microsystems. Now, another company named Oracle Corporation takes care of it and keeps it updated. New versions of Java come out regularly. Some versions, called 'Long Term Support' (LTS) versions, are supported for a longer time.

When Java was first being made, it was called Oak. Java is an 'object-oriented' language. This means it uses small parts called objects that work together to build programs. Its code looks a bit like other languages such as C, C++, or C#. However, code from those languages usually needs changes to work in Java.

Java can run on many different operating systems. This includes Android, which is the most popular mobile operating system in the world. Even though Google, Android's maker, now prefers Kotlin, Java is still widely used on Android. Because Java can run on many systems, it is called "platform independent". It does this by turning its code into something called bytecode. Then, a special program called the Java Virtual Machine (JVM) translates this bytecode into instructions your computer understands.

What Java Aims to Do

Java was created with five main goals in mind. These goals help make Java a strong and useful language:

  • Java should be easy to learn and use. It should also be 'object-oriented' and work well across different computer networks.
  • Java should be safe and reliable, meaning programs built with it should not crash easily.
  • Java should not depend on any specific type of computer or operating system. It should work everywhere.
  • Java programs should run well and be efficient.
  • Java should be able to be understood by an interpreter program. It should also support doing many tasks at once and allow flexible ways of handling data types.

The Java Platform

The Java platform is a set of software tools from Sun Microsystems. These tools help people create and run Java programs. A key part of this platform is the Java Virtual Machine (JVM). The JVM lets Java programs do the same things on different computer systems.

This ability to write software on one computer system and have it run on others is known as "cross-platform capability". It means a Java program made on a Windows computer can also run on a Linux computer or a Mac.

A Simple Java Program Example

Here is a very simple Java program. It is often the first program people learn to write. It just shows the words "Hello World!" on the screen.

/* * This is a simple program in Java.
 * It shows "Hello World!" on the screen.
 */
class HelloWorld {
    public static void main(String[] args) {
         System.out.println("Hello World!");
    }
}

Different Kinds of Java Programs

Java can be used to create many different types of programs. Each type runs in a slightly different way:

  • Java Applet - These are small programs that used to be downloaded from a website. They would run inside a web browser.
  • Application - This is a regular program that runs directly on your computer. If you get it online, you download it first.
  • JAR file (Java archive) - This is like a .zip file. It bundles many Java files into one single file.
  • Servlet - This type of program runs on a web server. It helps create web pages that you see in your browser.
  • Swing application - These programs have a GUI. A GUI means they have windows, buttons, menus, and other visual parts you can click on.
  • EJB (Enterprise Java Beans) - These run on a web server and are used to build very large and complex websites.

Why Java is Great

Java is often used to teach students how to program. Many professionals also use it for their work. Here are some reasons why Java is so good:

  • Safe Variables: Java makes sure that every variable (a place to store data) is given a starting value. In some older languages, if you forget to do this, it can cause strange errors.
  • Clear Return Types: Java requires that every method (a block of code that does a task) states what kind of value it will return. This helps prevent bugs because you always know what to expect.
  • Lots of Tools: Java comes with a huge collection of ready-to-use code, called the Java API. This means programmers don't have to write everything from scratch.
  • Consistent Data Sizes: Unlike some other languages, basic data types in Java (like 'int' for whole numbers) always take up the same amount of space. This helps programs work the same way on different computers.
  • Faster Computers: Java used to be thought of as slower than languages like C. But with today's fast computers, this difference is much less important.
  • Error Handling: Java has a special way to handle errors, like when a program tries to read a file that isn't there. This forces programmers to think about and fix possible problems.
  • Works Everywhere: A Java program written on one computer system can run on any other system that supports Java. You don't need to change the code at all! This means a program made for Windows can run on Linux or Mac.

Things People Criticize About Java

Even though Java is popular, some people have criticisms:

  • Generics and Type Erasure: Java added a feature called Generics to make code more flexible. However, to make sure old programs still worked, Java removes the specific type information during a step called 'compilation'. This can sometimes make Java behave in unexpected ways.
  • No Unsigned Numbers: Java does not have 'unsigned integer types'. These are numbers that are always positive. Other languages like C use them a lot. This can make it harder to share numeric data directly between Java and C programs. It also makes some Cryptography tasks more difficult in Java.
  • Limited Floating-Point Support: The IEEE has a standard for how computers handle numbers with decimal points (like 3.14). Java only supports some parts of this standard, not all of its advanced features.

Images for kids

See also

Kids robot.svg In Spanish: Java (lenguaje de programación) para niños

kids search engine
Java (programming language) Facts for Kids. Kiddle Encyclopedia.