开发者

Which Java compilers are available on Windows?

So, long story short, I need to use another Java compiler than what came with my Eclipse installation(Windows). I have to run some code that runs well in my other team member's computers (osx) but fails to run here. It seems the compiler I am using is way m开发者_如何学Core strict than theirs, so I am looking for a more relaxed compiler (until they fix their code to comply to my actual compiler).

What are the options available?

So, a totally stripped down version of the code is like this:

public class TreeSet <E extends Xpto & IOrderable<E>> implements SortedSet<E>, Cloneable {
...
}

public interface Xpto {}

interface IOrderable<E> extends Cloneable{
    boolean greaterEq(E e);
    IOrderable<E> clone();
}

being the error

"The inherited method Object.clone() cannot hide the public abstract method in IOrderable"


You have these options

  • Sun/Oracle (recommended)
  • IBM Jikes
  • gjc

But your main description sounds more like build specific problem. You can tweak them by right click on the project->Properties->Java Compiler.

UPDATE Clonable already provides a clone Method which is hidden. So you should strip that line from the IOrderable interface. In TreeSet clone has to be public.


Eclipse uses its own built-in one. You should probably try using the one which comes with the JDK.

Alternatively, have you tried changing the Eclipse compiler options, there's a lot you can tweak, including whether some code ends up with errors, warnings, or nothing. Look in either the project preferences or your workspace preferences, under Java > Compiler > Errors/Warnings. If you could give an example of the errors you're getting (and ideally the code which is failing), we could give more advice.


You should use an Ant build script, which when executed will in turn use the normal Sun Java compiler. See here for a simple build script. It's a good way of getting around the problems :)


Eclipse probably uses the one in the JDK, right? (wrong. from the comments: according to 1 commenter and 3 upvoters, Eclipse uses its own internal compiler, my bad. But that means you can use the one in the JDK too :D)

Anyway, you can try http://en.wikipedia.org/wiki/GCJ

Comments suggest this is not a compiler, although I do not agree. Please educate me on my wrongness and I'll gladly update or remove this answer.

From the wikipedia page :

The GNU Compiler for Java (GCJ or gcj) is a free software compiler for the Java programming language and a part of the GNU Compiler Collection. GCJ can compile Java source code to either Java Virtual Machine bytecode, or directly to machine code for any of a number of CPU architectures. It can also compile class files containing bytecode or entire JARs containing such files into machine code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜