Re: Compiling java (gcj, jikes, kaffe...)
- To: Debian User <debian-user@lists.debian.org>
- Subject: Re: Compiling java (gcj, jikes, kaffe...)
- From: Andreas Hetzmannseder <hetzmann@netway.at>
- Date: Sun, 4 Feb 2001 19:35:55 +0100
- Message-id: <[🔎] 20010204193555.A262@k-star>
- In-reply-to: <20010130161804.B22909@harmony.cs.rit.edu>; from dsh8290@rit.edu on Tue, Jan 30, 2001 at 04:18:04PM -0500
- References: <20010127204304.A1151@k-star> <20010130161804.B22909@harmony.cs.rit.edu>
Thanks very much, D-Man,
Sorry for my late reply, I was on a holiday.
I have no experience with C/C++ yet, but I will keep your explanations,
as I am willing to learn.
On Tue, Jan 30, 2001 at 04:18:04PM -0500, D-Man wrote:
> On Sat, Jan 27, 2001 at 08:43:04PM +0100, Andreas Hetzmannseder wrote:
> | Dear debian-users,
> |
> | This is really stupid, but I don't know any further.
> | Every time I try to compile some java source code - actually the HelloWorld
> | example from the Debian Java FAQ - I get error messages:
> |
> | with gcj:
> | /usr/lib/crt1.o: In function `_start':
> | /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
> | collect2: ld returned 1 exit status
>
> gcj outputs C++ object files from the Java source. Then (unless you
> gave it the -c option) it links it to form an ELF binary (just like
> C/C++). The problem is the linker can't find main.
>
> int main( int argc , char** argv )
> {
> /* ... */
> return 0 ;
> }
>
>
> The solution is to tell gjc where main is:
>
> gcj --main=MyJavaClassDefiningMain *.java
>
>
> gcj will then run a script (installed with it) to spit out some C/C++
> code with the appropriate main() function that will call the main you
> defined in your Java class. If you give gcj the -c option it will
> stop when it has produced C++ object files (.o). You can then link
> them at the end.
>
> gcj also has a -C option will tells it to output Java bytecodes
> (.class) instead. These will then need some JVM (jre, kaffe, etc) to
> run.
The -C option is exactly what I needed...
>
> |
> | with jikes:
> | Found 2 system errors:
> |
> | *** Error: Could not find package named
> | /usr/share/java/repository/java/util
> |
> | *** Error: Could not find package named
> | /usr/share/java/repository/java/lang
> |
>
> The packages java.util and java.lang can't be found by the compiler.
> I haven't used jikes before so I can't be more specific. Maybe a
> CLASSPATH problem?
I managed to run the following:
jikes -classpath /usr/share/java/libgcj.zip MyApp.java
I still don't know what to do with /usr/share/java/repository - it's
empty...
> | with kaffe's kjc:
> | java.lang.NoClassDefFoundError: at/dms/kjc/Main
> | at java.lang.Throwable.<init>(Throwable.java:38)
> | at java.lang.Error.<init>(Error.java:21)
> | at java.lang.LinkageError.<init>(LinkageError.java:21)
> | at java.lang.NoClassDefFoundError.<init>(NoClassDefFoundError.java:21)
> |
>
> I guess that kjc is a shell script that tries to run a java program.
> Apparently the main() function here is in the class "Main" in the
> package "at.dms.kjc" and the class can't be found. This is definitely
> a CLASSPATH problem.
>
> When I tried out kaffe, it had the commands "javac" for compiling and
> "java" for executing bytecodes. I think they were really just
> symlinks to the kaffe commands. Perhaps trying these commands will
> help?
javac is not available in my version of kaffe (1.0.5)
> | BTW: Running ready programs with kaffe works just fine...
> |
> | I put the following entry into my ~/.profile:
> | export CLASSPATH=/usr/share/kaffe
>
> I would recommend against this. At my present job I am using a Win2k
> box (with cygwin of course) and Sun's jdk. I found it is much better
> to make a whole collection of shell scripts that execute the proper
> JVM (I have 1.1.8, 1.2.2, and 1.3 installed) with the proper classpath
> stuff on the command line. [...]
For the time being I only have kaffe's JVM installed (Sun's jdk 1.2 is
running with win95...) - I will keep this in mind when it comes to
additional JVMs.
Thank you very much again,
Andreas.
Reply to: