Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-22-2004, 06:28 PM   #1
Registered: Feb 2004
Distribution: Arch
Posts: 498

Rep: Reputation: 31
How does the gcc-java program work?

I searched for this but all I found were GCJ pages or GCC for C/C++ pages, but how do I compile and run java programs with the gcc-java package installed. And does this require any other gcc stuff? (can't remember if there is a base gcc package, but if there is do I need it?)
Old 06-22-2004, 08:01 PM   #2
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Isn't it exactly (almost maybe ) like compiling g++?. To compile:

gcj -c -g -O

to link it, use the command:

gcj --main=Hello -o Hello Hello.o

The only thing different is the "--main=Hello" thing, that, as far as I understand, refers to the main class from your code(?). That should create an executable called "Hello", that you should be able to run with ./Hello. Otherwise, make it executable (chmod +x Hello).

If you want to create .class files like javac does, use -C as argument (gcj -C).

Last time I've checked, gcj had support to java.lang,, java.util,,, java.sql and java.math packages, but not graphical ones like AWT and Swing.

As you see, there're many limitations using gcj, specially when it comes down to gui's applications. Personally, I love Java, but I dislike many things coming from Sun, one of them, is letting Java being closed source, thus, not very suitable for Open Source projects. Let's keep out fingers crossed for gcj
Old 06-22-2004, 09:31 PM   #3
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
GCJ is the Java front-end for GCC. GCJ requires that you also have the g++ package installed (which is almost always present along with your GCC installation).

The GCJ page ( ) has some good info to get you started.

Last edited by johnMG; 06-22-2004 at 09:32 PM.
Old 06-22-2004, 11:33 PM   #4
Registered: Feb 2004
Distribution: Arch
Posts: 498

Original Poster
Rep: Reputation: 31
Is gcc-java (the package I see in slack 9.1) the same thing as gcj?

so to make a .class is it

gcj -C -g -O
gcj -C
is gcj -c -g -O the command for machine native code??? What is the point of this I don't understand.

So with gcj is it impossible to do GUI or just really really hard because you have to right the AWT and Swing code yourself?? Does the code stay platform independent? And are there any non Sun compilers that support GUI classes?
Old 06-22-2004, 11:40 PM   #5
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
vdogvictor, read up on the gcj site. Read the FAQ's there. Also go to the LQ wiki and read there about Java (there's some info on GCJ).

You can do GUI code with GCJ, but it's a bit limited at the moment. You write it by-hand, and it's not difficult.

As megamanX was saying, using the gcj command is analogous to using the g++ command (for compiling C++ code), with a few small exceptions (such as the --main option).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop java program(threaded program..should end cleanly) rmanocha Programming 4 11-09-2004 09:36 AM
use gcc or javac for java compile? jordanGSU Programming 22 10-15-2004 09:12 AM
Updated Java... now java apps dont work zidane2010 Linux - Software 6 05-04-2004 08:02 PM
gcc, gcj, and java problems weppnesp Linux - Software 0 06-15-2003 06:34 PM
Java compiled with gcc-3.2 CragStar Linux - Software 5 01-15-2003 01:50 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:12 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration