0

Is there a known issue with GCJ and using <Void, Void>? My code works fine without it, but trying to compile it to an exe using gcj fails:

$ gcj -c -g -O Program.java
Program.java:25: error: '{' expected.
        class Task extends SwingWorker<Void, Void> {
                                         ^
Program.java:25: error: Class or interface declaration expected.
        class Task extends SwingWorker<Void, Void> {
                                         ^
Program.java:25: error: .
        class Task extends SwingWorker<Void, Void> {
                                         ^
3 errors

Additionally, if I remove <Void, Void> (so my code doesn't function 100%), I get these further down the line:

$ gcj -c -g -O Program_Full.java
Program.java:10: error: Class or interface `javax.imageio.ImageIO' not found in import.
   import javax.imageio.ImageIO;
          ^
Program.java:25: error: Superclass `SwingWorker' of class `Program$Task' not found.
        class Task extends SwingWorker {
                              ^
2 errors

My code compiles and runs great, it just seems like GCJ doesn't like certain aspects. Bad version? I just downloaded it: gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

carget
  • 77
  • 6

1 Answers1

0

I don't know where gcj is at in the current version, or what your version supports, but it looks like you're using a version that doesn't have the Java 5 and newer language features such as generics.

I'd recommend forgetting about gcj and use the Oracle JDK instead to compile and run your Java programs. In my opinion, gcj is not useful for any serious Java software development.

Jesper
  • 202,709
  • 46
  • 318
  • 350
  • My main reason to use gcj was for compiling to native code. What would you suggest for that? It's nothing major, just a small app I would like as an exe rather than a jar or anything else. – carget Dec 22 '11 at 09:29
  • Why would you want to do that? Even when you compile to a native exe, it would still require the Java runtime libraries to run, and it also won't run faster just because it's native code. Java is unfortunately probably not the best tool if you want a small native exe... – Jesper Dec 22 '11 at 09:32
  • Ah, I've already coded everything in Java. So there's no way to make it a standalone exe? – carget Dec 22 '11 at 09:35
  • There are tools that can do that (search for "java exe", for example), but as far as I know you'll always need Java runtime libraries to make the resulting exe run; so if you want to run it on other computers it's not as easy as just copying the exe. – Jesper Dec 22 '11 at 09:49