You are not logged in.
Pages: 1
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 ).
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.
$ 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.
"Gentlemen! You can't fight in here! This is the war room!"
--President Merkin Muffley
Offline
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
$ 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
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
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
Try something else:
pacman -S java-gcj-compatThat 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.
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 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
Pages: 1