Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java JRE vs GCJ

Tags:

I have this results from a speed test I wrote in Java:

Java  real        0m20.626s user        0m20.257s sys         0m0.244s  GCJ  real        3m10.567s user        3m5.168s sys         0m0.676s 

So, what is the purpose of GCJ then? With this results I'm sure I'm not going to compile it with GCJ!

I tested this on Linux, are the results in Windows maybe better than that?

This was the code from the application:

public static void main(String[] args) {     String str = "";     System.out.println("Start!!!");     for (long i = 0; i < 5000000L; i++) {         Math.sqrt((double) i);         Math.pow((double) i, 2.56);         long j = i * 745L;         String string = new String(String.valueOf(i));         string = string.concat(" kaka pipi"); // "Kaka pipi" is a kind of childly call in Dutch.          string = new String(string.toUpperCase());         if (i % 300 == 0) {             str = "";         } else {             str += Long.toHexString(i);         }     }     System.out.println("Stop!!!"); } 

I compiled with GCJ like this:

gcj -c -g -O Main.java gcj --main=speedtest.Main -o Exec Main.o 

And ran like this:

time ./Exec                     // For GCJ time java -jar SpeedTest.jar    // For Java 
like image 580
Martijn Courteaux Avatar asked Jun 13 '10 15:06

Martijn Courteaux


People also ask

Is Java and JDK version same?

The Java Development Kit (JDK) is part of the Java SE Product, there are other parts as well, but you can treat them as the same thing for development purposes.

What is the default-JRE package?

default-jre It installs the "Standard Java or Java compatible Runtime", which is OpenJDK 7 JRE. This package points to the Java runtime, or Java compatible runtime recommended for the i386 architecture, which is openjdk-7-jre for i386.

What is Java default jdk?

JDK (Java Development Kit) is a software development environment used in Java platform programming. It contains a complete Java Runtime Environment, a so-called private runtime.


1 Answers

GCJ is obsolete. It was started a long time ago because people wanted an open-source alternative to the Sun JDK, and it was never particularly good. Now that Sun open-sourced their JDK, there's absolutely no reason to use GCJ (but it still lurks in some Linux distros).

like image 88
Mike Baranczak Avatar answered Jan 06 '23 10:01

Mike Baranczak