Compiles in IDE but not from javac

Hi,

I have been using a java 1.5 library to do some new graphical stuff and noticed the following.

I can compile my source in my IDE (Eclipse) using java 1.4 and run using java 1.4 even though the library is 1.5. When I enter the screen that requires the 1.5 java I get major minor exceptions atruntime.

When I build though ant using javac the application wont build using 1.4 as it complains about the library jar atcompile time.

The behaviour I am getting in eclipse is actually favorable as these new screen are only for clients running java 1.5.

Is there a way to replicate the behavior I get in eclipse in javac to compile my app with 1.4?

Thanks a Mill,

Anthony Brew

[737 byte] By [Anthony-Brewa] at [2007-10-2 22:17:15]
# 1

If it was me I wouldn't consider that a good thing. 1.5 changed the way it builds things. Someone who is using 1.5 might want to have it actually do it that way.

Other than that you might want to be explicit about what you mean when you say it "wont build using 1.4". Are you using the Sun JDK 1.4? If so what version? Or are you using a 1.5 JDK with appropriate flags set?

jschella at 2007-7-14 1:34:20 > top of Java-index,Developer Tools,Java Compiler...
# 2
Eclipse is known to have an internal compiler that's at places rather buggy.Your code is broken, fix it. Don't try to trick the compiler into accepting it anyway.
jwentinga at 2007-7-14 1:34:20 > top of Java-index,Developer Tools,Java Compiler...
# 3

Ok, I accept my code is broken. I had the problem wheer our project was moved to 1.5 and then there was a backstep by management and we suddenly have to be 1.4 compliant. This causes problems as the code requires 1.5 features from the new jar.

I thought I could negoiate and explain the new screen would not be avaialble unless the client ran 1.5 (ie no more code for me to write).

The code I wrote is not broken, I wrote 1.5 code but as I said I am stuck with a 1.5 library that I have been told I am not allowed to mess with (i.e retroweaver).

The problem now is I will have to handcraft alot of these new components or replacements (from swinglabs) and the ones there were pretty good.

Anyway thanks for the help, but I think you can see I am between a rock and a hard place.

Anthony-Brewa at 2007-7-14 1:34:20 > top of Java-index,Developer Tools,Java Compiler...
# 4
nothing that was added in 1.5 is required to do anything, it's all icing on the cake and raisins in the applepie, nice to have but you can live without it.
jwentinga at 2007-7-14 1:34:20 > top of Java-index,Developer Tools,Java Compiler...
# 5

Hi,

I found a way around it, cant believe it wasnt the first thing I did. I would like to point out its the external library that is 1.5 not my code.

I compile my source with the 1.5 compiler but target 1.4 bytecode, then in the section of my code that shows the new funky swinglabs screen I simple have a old version showing when the user is running 1.4. This works because the swinglabs class is dynamically loaded at runtime and as we never get to the screen its never loaded into the JVM.

This may seem dirty to you but, what it does do is woo client onto using 1.5 JRE, the new screens are essentially bells and wistles but when they run on 1.5 they will notice them and hopefully upgrade their version of java.

Anthony-Brewa at 2007-7-14 1:34:20 > top of Java-index,Developer Tools,Java Compiler...
# 6

>

> I compile my source with the 1.5 compiler but target

> 1.4 bytecode, then in the section of my code that

> shows the new funky swinglabs screen I simple have a

> old version showing when the user is running 1.4.

> This works because the swinglabs class is dynamically

> loaded at runtime and as we never get to the screen

> its never loaded into the JVM.

>

> This may seem dirty to you but, what it does do is

> woo client onto using 1.5 JRE, the new screens are

> essentially bells and wistles but when they run on

> 1.5 they will notice them and hopefully upgrade their

> version of java.

Nothing wrong with that.

However you might want to keep in mind that given that version 6 is now in beta it means that very shortly you can expect to see 1.4 enter the end of life process (once 6 is released.) You might want to consider what your strategy for that is going to be.

jschella at 2007-7-14 1:34:20 > top of Java-index,Developer Tools,Java Compiler...