Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Newbie needs help with gcj

Thread view: 
Marc Shapiro - 06 Apr 2006 07:24 GMT
I am trying to teach myself java.  In order to actually understand the
basics, I am using command line tools and not a full blown IDE.  I am
using the O'Reilly book "Learning Java" (Tiger).  I am running a Debian
GNU/Linux box.

The introductory programs include the obligatory console based "Hello,
Java" and four others that use javax.swing and add various eye-candy.
They all compile fine with javac and run with the "java" VM.  I decided
to try and compile them natively using gcj (just for chuckles and
grins).  The console based program compiles and runs just fine.  The
others compile, but then give me the following run time errors:

~/Projects/Java$ hello-java1
Exception in thread "main" java.lang.Error: not implemented
   at javax.swing.UIDefaults.put(java.lang.Object, java.lang.Object)
(/usr/lib/libgcj.so.4.0.0)
   at javax.swing.plaf.basic.BasicDefaults.BasicDefaults()
(/usr/lib/libgcj.so.4.0.0)
   at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults()
(/usr/lib/libgcj.so.4.0.0)
   at javax.swing.UIManager.getDefaults() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.UIManager.getUI(javax.swing.JComponent)
(/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JPanel.updateUI() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean)
(/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JPanel.JPanel() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JRootPane.createGlassPane() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JRootPane.getGlassPane() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JRootPane.JRootPane() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JFrame.createRootPane() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JFrame.getRootPane() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JFrame.frameInit() (/usr/lib/libgcj.so.4.0.0)
   at javax.swing.JFrame.JFrame(java.lang.String)
(/usr/lib/libgcj.so.4.0.0)
   at HelloJava1.main(java.lang.String[]) (Unknown Source)

Is there something extra that I need to do with swing programs to get
them to compile and run natively using gcj?

Marc Shapiro
jlp - 06 Apr 2006 07:33 GMT
gcj does't not implement all the swing libraries.

> I am trying to teach myself java.  In order to actually understand the
> basics, I am using command line tools and not a full blown IDE.  I am
[quoted text clipped - 37 lines]
>
> Marc Shapiro
Ian Wilson - 06 Apr 2006 15:05 GMT
> I am trying to teach myself java.  In order to actually understand the
> basics, I am using command line tools and not a full blown IDE.  I am
[quoted text clipped - 11 lines]
> Exception in thread "main" java.lang.Error: not implemented
>    at javax.swing.UIDefaults.put(java.lang.Object, java.lang.Object)

<similar errors snipped>

> Is there something extra that I need to do with swing programs to get
> them to compile and run natively using gcj?

gcj doesn't support the whole set of Java classes that are standard with
the Sun runtime (JRE) or developer tools (JDK). You can read more about
this at the GCJ home page. I recall there are a couple of significant
ongoing projects to fill these gaps.

You can obtain the Sun JDK for free from Sun. No doubt a Debian package
is also available from the usual Debian repositories. I'd suggest you
use this unless you have some overriding ethical reason for choosing GNU
tools.
Marc Shapiro - 06 Apr 2006 15:18 GMT
> gcj doesn't support the whole set of Java classes that are standard with
> the Sun runtime (JRE) or developer tools (JDK). You can read more about
[quoted text clipped - 5 lines]
> use this unless you have some overriding ethical reason for choosing GNU
> tools.

Not at all.  I have the JDK1.5.0_06 installed and that is what I am
using.  I just wanted to try and play around with compiling to native
code instead of to bytecode.  That is what I was using gcj for.  Does
the jdk have a similar compiler?  If not, well, it would be nice, but I
can live without it since gcj is obviously not yet complete enough to
handle anything beyond console programs.  For that I could just use python.

Marc Shapiro
Ian Wilson - 06 Apr 2006 17:10 GMT
>> gcj doesn't support the whole set of Java classes that are standard
>> with the Sun runtime (JRE) or developer tools (JDK). You can read more
[quoted text clipped - 10 lines]
> code instead of to bytecode.  That is what I was using gcj for.  Does
> the jdk have a similar compiler?  

There are commercial compilers that can produce native executables (e.g.
some versions of JBuilder). I've not tried them. I hear that anything
that uses Swing will have to rely on the JRE being installed since Sun
prohibits separate deployment of the DLL's that Swing needs. You may be
OK if you use SWT instead of Swing.

There's lots of interesting stuff out there but I suspect that producing
native binaries is non trivial. e.g. http://swingwt.sourceforge.net/ 
says "Developers deploying to *nix/Win32 can compile natively with GCJ
and the applications can be distributed without a VM." But I think you
may have to change references to javax.swing in your .java code.
Micah Cowan - 06 Apr 2006 19:58 GMT
> >> gcj doesn't support the whole set of Java classes that are standard
> >> with the Sun runtime (JRE) or developer tools (JDK). You can read
[quoted text clipped - 15 lines]
> since Sun prohibits separate deployment of the DLL's that Swing
> needs. You may be OK if you use SWT instead of Swing.

Well, separately redistributing the DLLs would be a violation of
copyright, but reimplementation would be alright. Doesn't the IBM JDK
have a reimplementation of Swing?

Signature

Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/

Marc Shapiro - 06 Apr 2006 21:43 GMT
> There are commercial compilers that can produce native executables (e.g.
> some versions of JBuilder). I've not tried them. I hear that anything
[quoted text clipped - 7 lines]
> and the applications can be distributed without a VM." But I think you
> may have to change references to javax.swing in your .java code.

It looks like swingwt would do the job, and I may look into it further
later on.  For now, however, I think that I am probably better off just
working my way through a book, or two, dealing with standard java and
swing.  Until I get the hag of the standard stuff, trying to do other
things will probably just add to my confusion.

Thanks for the pointer, though.

Marc Shapiro
Monique Y. Mudama - 07 Apr 2006 04:42 GMT
["Followup-To:" header set to comp.lang.java.help.] On 2006-04-06,
Marc Shapiro penned:

> It looks like swingwt would do the job, and I may look into it
> further later on.  For now, however, I think that I am probably
> better off just working my way through a book, or two, dealing with
> standard java and swing.  Until I get the hag of the standard stuff,
> trying to do other things will probably just add to my confusion.

If it makes you feel better, lots of people who've been working in
Java for years (myself included) have never compiled a java app to a
native binary.  I've just never needed to, and it seems like you lose
a lot of flexibility by doing so.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.