You are not logged in.

#1 2008-05-11 19:33:27

jrick
Member
Registered: 2008-01-16
Posts: 27

GCJ and GIJ

I'm trying to use GCJ and GIJ as my jre and jdk as replacements for Sun's java and javac (and then eventually, use the runtime and jdk in Groovy big_smile).

I am able to compile a simple java program using gcj, but am not able to use gij to interpret the bytecode.

MainClass.java

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

Like I said, very simple. tongue

$ gcj -C MainClass.java
$ gij MainClass
Exception in thread "main" java.lang.NoClassDefFoundError: MainClass
   at gnu.java.lang.MainThread.run(libgcj.so.9)
Caused by: java.lang.ClassNotFoundException: MainClass not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/lib/], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.9)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.9)
   at java.lang.ClassLoader.loadClass(libgcj.so.9)
   at java.lang.ClassLoader.loadClass(libgcj.so.9)
   at gnu.java.lang.MainThread.run(libgcj.so.9)

I am able to use GCJ to compile directly to machine code and run the binary, but that won't really help me much when trying to write Groovy scripts. wink


"Gentlemen! You can't fight in here! This is the war room!"
--President Merkin Muffley

Offline

#2 2008-05-18 06:34:50

ScriptDevil
Member
From: In Front of My PC
Registered: 2006-04-06
Posts: 253

Re: GCJ and GIJ

I can suggest something I learnt at college. Is the current directory in the classpath?


Be yourself, because you are all that you can be

Offline

#3 2008-05-23 02:04:57

jrick
Member
Registered: 2008-01-16
Posts: 27

Re: GCJ and GIJ

$ echo $CLASSPATH
/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/lib
$ gcj -C MainClass.java
$ gij MainClass
Exception in thread "main" java.lang.NoClassDefFoundError: MainClass
   at gnu.java.lang.MainThread.run(libgcj.so.9)
Caused by: java.lang.ClassNotFoundException: MainClass not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/lib/], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.9)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.9)
   at java.lang.ClassLoader.loadClass(libgcj.so.9)
$ export CLASSPATH=$CLASSPATH:$(pwd)
$ gij MainClass
Hello, World!

So it works, but why?  And is there any way around this problem?


"Gentlemen! You can't fight in here! This is the war room!"
--President Merkin Muffley

Offline

#4 2008-06-18 17:09:29

kesara10
Member
Registered: 2008-06-11
Posts: 13

Re: GCJ and GIJ

Put the current directory in your CLASSPATH variable as below. Set it in .profile or .bashrc or .bash_profile
export CLASSPATH=.:$CLASSPATH

Last edited by kesara10 (2008-06-18 17:10:09)

Offline

#5 2008-06-18 19:03:18

JGC
Developer
Registered: 2003-12-03
Posts: 1,664

Re: GCJ and GIJ

Try something else:
pacman -S java-gcj-compat

That will give you a full blown java5 compatible JRE/JDK environment with java, javac, jar, etc included. It uses gij as runtime and eclipse-ecj as compiler (gcj compiles with this compiler internal btw).

Offline

#6 2008-06-23 01:59:03

jrick
Member
Registered: 2008-01-16
Posts: 27

Re: GCJ and GIJ

JGC wrote:

Try something else:
pacman -S java-gcj-compat

That will give you a full blown java5 compatible JRE/JDK environment with java, javac, jar, etc included. It uses gij as runtime and eclipse-ecj as compiler (gcj compiles with this compiler internal btw).

That's what I tried before, when it was throwing the CLASSPATH errors. smile

kesara10 wrote:

Put the current directory in your CLASSPATH variable as below. Set it in .profile or .bashrc or .bash_profile

Thanks, that would probably work, however I'm in the process of switching my desktop from Arch Linux to FreeBSD.  And since the FreeBSD port for java-gcj-compat is broken, I'm not going to install it right now (opting for Sun's Java), and won't be able to try your suggestion.

I'll probably still hang around here answering questions if I can; Arch is still the best Linux distribution wink  and will be on my list of backups in case I run into any hardware that doesn't play nicely with a BSD.


"Gentlemen! You can't fight in here! This is the war room!"
--President Merkin Muffley

Offline

Board footer

Powered by FluxBB