After midnight, part 3: Java
Friday 5. October, 2007
As I took the Programming course at the University, I was faced with this beast. The course is about programming and how to program in Java. Even though I have never before even seen actual Java code, I’ve always been hating it. Some Java programs just seem to be so goddamn slow even if they don’t appear doing anything special (well, Azureus might have been the app in question, not sure about it).
Anyhow, here’s the Hello World in Java:
public class HelloThere {
public static void main(String args[]) {
System.out.println("Hello there!");
}
}
Save in a file with exactly the same name as the class + “.java” in this case “HelloThere.java”. As you have installed Java Development Kit, or the SDK, (Java runtime is NOT enough), compile the java file with
javac HelloThere.java
This will create a corresponding class-file which is the bytecode version of the source code, and as far as I know, the closest form of a binary you can get with javac. And run it with
java HelloThere
Note: If you are using Linux environment you might not need Sun’s Java environments at all. Gnu Compiler Collection (GCC) contains a Java compiler (gcj), that can produce even native binary code. Be warned though, the gcj is compatible with 1.4-series, which means that newer features won’t be available such as the java.util.Scanner -class for reading user input in console applications.
Search the net and you should be able to find Java tutorials easily and among them a lot of posts on various forums telling you you shouldn’t use Java in the first place.