hello friends! new(ish)!

Java (programming language)

From InstallGentoo Wiki v2
Jump to navigation Jump to search

Not to be confused with JavaScript.

Java is a class-based, object-oriented programming language that was specifically designed to avoid implementation dependencies.

Java Runtime Environment

The Java Runtime Environment or JRE should not be confused with the Java programming language itself.

The JRE is a software package that is required to run applications written in the Java programming language. It includes the Java Virtual Machine or JVM, the Java platform core classes, supporting Java platform libraries, and various Java plug-ins for popular web browsers. The JVM is responsible for the versatility of Java applications in terms of platform support. Unfortunately, it is also responsible for their relatively poor performance and high memory requirements. While the situation has certainly improved in recent years thanks to the Just-In-Time Compiler or JIT, Java applications still tend to be somewhat slower and heavier than their non-Java counterparts. Notably, some applications like Libre Office require Java for certain features, but can be used without the JRE if the user is willing to sacrifice access to those features.

The JVM created by Sun Microsystems and Oracle is a proprietary software program, and other software programs have been made to replace it, such as OpenJDK.

Security Issues

The vast majority of the JRE's security issues stem from the various Java plug-ins for Web browsers. These plug-ins have no role whatsoever in running most Java applications, and they are only rarely required to display modern Web content. Due to the significant number of security vulnerabilities caused by these plug-ins in the past several years, major browser vendors like Mozilla and Google have taken steps to see that they are unable to execute without directly prompting the user.

Speed issues

Due to its nature, Java is often resource heavy. Java often times slows the users computer and crashes. Speed issues have been improved over the years, but because of this, many people choose to avoid Java programs.

History

Java's development began in 1991. Originally, Java was intended to be a language designed for interactive television, but the idea was scrapped, because that would be complex for television at the time. There was many ideas for the name of the language: Oak, Green, but Java was picked. The language was released to public in 1996. The first public version was 1.0.

Examples

Hello World

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

FizzBuzz

class FizzBuzz {
    public static void main(String[] args) {
	for (int i = 1; i <= 100; i++) {
	    if (i % 3 == 0 && i % 5 == 0) {
		System.out.println("FizzBuzz");
	    } else if (i % 3 == 0) {
		System.out.println("Fizz");
	    } else if (i % 5 == 0) {
		System.out.println("Buzz");
	    } else {
		System.out.println(i);
	    }
	}
    }
}