« Return to Thread: Compatibility with Sun's java

Re: Compatibility with Sun's java

by Marco Trudel :: Rate this Message:

| View in Thread

Andy Pepperdine wrote:

> Folks, I hope this is not stupid question for this mailing list.
>
> A year ago I wrote, purely for amusement and self teaching after I
> retired, a program in Java which was intended to be cross-platform, and
> accessible both as a straight jar archive, and also as an applet in a
> web-page. In addition, it can be run without any graphical interface
> (controlled by a command line switch), so it can be used to generate
> things offline in a script. I surprised myself and got it working
> precisely as I expected. (It remains the only java program I've
> written.)
>
> I was using Sun Java JDK 1.4 initially, but the system I was using has
> had its Linux (Suse) upgraded and it now has Sun's 1.5, but the builds
> still worked and the results are fine. There is only simple use of
> swing as I was learning as I went.
>
> I've put Kubuntu on a laptop, and before messing around with Sun's
> Java, I thought I'd give gcj a try as it comes with the installation.
>
> However, I've immediately hit serious problems.
>
> 1. I first tried using gij on the existing (Sun generated) jar files. It
> starts, but the initial display is wrong (two of the text panes contain
> only the first line of text, and not the rest). It responds very slowly
> - we're talking an order of magnitude or more slower than Sun's java.
> And the display does not always get updated after an action, but only
> after something else triggers a rewrite, but I can't figure out what
> triggers it. There are other problems with the text pane, too as it
> seems to produce multiple copies of the text put into it. But on the
> whole it seems to work, although it is not usable in practice.

You are using GCJ/GIJ 4.1.0. I wouldn't expect too much of AWT/Swing
with that version.


> 2. When I added the no-display parameter to the invocation the output
> came out rapidly and correctly, so it looks like it is swing that is
> far too slow. I also noticed that it threw up the following at the
> beginning, even though it should not have even tried to display
> anything at all.
>
> [quote]
> X Error: BadDevice, invalid or uninitialized input device 166
>   Major opcode:  145
>   Minor opcode:  3
>   Resource id:  0x0
> Failed to open device
> X Error: BadDevice, invalid or uninitialized input device 166
>   Major opcode:  145
>   Minor opcode:  3
>   Resource id:  0x0
> Failed to open device
> [/quote]

Well, updating GCJ would definitively make sense.


> 3. I then tried to run the make using gcj and fastjar. It compiled
> and created the jar archives without any failures being reported, but an
> attempt to run the resulting file got this:
>
> [quote]
> andrew@laptop:~/Dev/Products/Sokuku/1.0-3$ gij -jar Sokuku-en-1.0-3.jar
> Failed to load Main-Class manifest attribute from Sokuku-en-1.0-3.jar
> [/quote]

You probably forgot to add the Main-Class attribute to the manifest...


> I'd like to know whether it is worthwhile trying to do any more, or
> should I wait until a later version of gcj? - bearing in mind I do not
> have much time to tinker with things these days. Or should I wait until
> Sun's java appears as a regular Ubuntu package probably later this year?

If you want a regular Ubuntu package, you should wait and test whatever
comes your way. If you want to have it running now, you can easily
download and use a Sun JRE or, if you have some knowledge of compiling
and alike, download the latest GCJ source and try with it. Although I
doubt GCJ 4.3 (GNU Classpath 0.93) has already complete AWT/Swing
support. But I really don't know.


> I found Dan Bolser's howto from 2004 but he seems to be generating
> native code which I'm not interested in because I want cross-platform
> use. Is there a howto for a simple java "Hello world" from a jar file
> anywhere?

Well, that would then more be Java basics. Just ask google...


Marco

 « Return to Thread: Compatibility with Sun's java