Compatibility with Sun's java

View: New views
4 Messages — Rating Filter:   Alert me  

Compatibility with Sun's java

by Andy Pepperdine :: Rate this Message:

| View Threaded | Show Only this Message

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.

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]

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]

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?

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?

Version information:
[quote]
andrew@laptop:~$ gij --version
java version "1.4.2"
gij (GNU libgcj) version 4.1.0 (Ubuntu 4.1.0-1ubuntu8)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
andrew@laptop:~$ gcj --version
gcj (GCC) 4.1.0 (Ubuntu 4.1.0-1ubuntu8)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

andrew@laptop:~$ jar --version
jar (fastjar) 0.92-gcc-4.0

Copyright 1999, 2000, 2001  Bryan Burns
Copyright 2006 Free Software Foundation
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
andrew@laptop:~$
[/quote]

Could it be useful as a test case? A description of the program is to
be found at http://www.pepperdine.eclipse.co.uk/Sudoku/Description.html
which links to both a README text file giving details of the parameters
that can be passed, as well as an html page that contains the applet.

The jar file to be executed is found at:
http://www.pepperdine.eclipse.co.uk/Sudoku/en/Sokuku-en-1.0-2.jar

There is another executable jar file at
http://www.pepperdine.eclipse.co.uk/Sudoku/en/Sokuku-en-1.0-2-all.jar
which contains the source as well. Unzipping this file in a new
directory, and then untar'ing the file src.tgz will create the src
directory. Issuing make for the outer level Makefile should create all
the target jar files.

Andy.


Re: Compatibility with Sun's java

by Marco Trudel :: Rate this Message:

| View Threaded | Show Only this Message

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

Re: Compatibility with Sun's java

by Andy Pepperdine :: Rate this Message:

| View Threaded | Show Only this Message

On Monday 29 January 2007 18:55, Marco Trudel wrote:
> Andy Pepperdine wrote:
[...]

> >
> > 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.

OK, understand. If I've got time, I'll look to get a later version.

[...]

>
> > 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...

If I unpack the archive, and look in META-INF/MANIFEST.MF I find the line:
Main-Class: Sokuku.Main
the same as when built with Sun's java.

When I give the archive generated by gcj and fastjar to Sun's java, it
complains the archive is corrupt.
[...]
>
> 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 might try that. The AWT/Swing is very simple stuff.
[...]

Thanks for the info.

Andy.

Re: Compatibility with Sun's java

by Tom Tromey :: Rate this Message:

| View Threaded | Show Only this Message

>>>>> "Andy" == Andy Pepperdine <andy@...> writes:

>> > 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]

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

Andy> If I unpack the archive, and look in META-INF/MANIFEST.MF I find
Andy> the line:
Andy> Main-Class: Sokuku.Main
Andy> the same as when built with Sun's java.

Offhand I don't know.  I think this has worked for a long time... but
perhaps there is some bug we fixed between 4.0 and today.

Tom