The moose likes Beginning Java and the fly likes Using JDK 5 lib with 1.4 application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using JDK 5 lib with 1.4 application" Watch "Using JDK 5 lib with 1.4 application" New topic

Using JDK 5 lib with 1.4 application

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178

I'm about to use a 3rd party library that makes use of JDK 5 features (like annotations and typed collections). The application I have to develop must use JDK 1.4. Do I have to expect any problems? I'm thinking of something like a method returning a List<String> but I assign the return to an 1.4-style List? The library's documentation says that one needs JDK 1.3 or above to use it, but the documentation isn't that good anyway.
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 9963

If you are using Java1.4 in your application then you wont be able to use 3rd party libraries that are compiled using Java5

[My Blog] [JavaRanch Journal]
Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Can someone confirm this?
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
I could be wrong but I dont see how the JDK 1.4 Javac can begin to understand the "new" features of 1.5, annatations it might ignore, but generics (List<String> its just not going to have a clue about.

You coudl easierly test by creating a small library using 1.5 language features and see if 1.4 handles it, as I said, i dont think it will, but could be wrong.
It is total possible to take JAR's from different versions of JDK's and use them in older versions. However Generics isint a library, its a language feature which needs Javac support, so any libraries/JAR that relie on a new language feature arent going to work. (at least thats my view)

I would (try) find a JDK 1.4 version, of the library you need.


[ April 16, 2007: Message edited by: Gavin Tranter ]
[ April 16, 2007: Message edited by: Gavin Tranter ]
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41188
Out of the box, it will not work. The library may be amenable to a treatment of Retroweaver, which would create a Java 1.4-compatible version - if its license allows that.

Ping & DNS - my free Android networking tools app
Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Okay, I took the sample application provided with the library and took a look. It used annotations to suppress warnings regarding unchecked conversions of collections. I had to remove the annotations, of course.

Then I changed some stuff concerning the typed collections and the new for-loop to make it (the sample application!) 1.4-compatible. I do get a 1.4-collection I have to treat the old-fashioned way when looping through it (casting), but I do get a List. To be more specific: the API says that getHTMLReport() returns List<String> and I do

The list is "okay" and I can loop through it. Unfortenately, I do get an error later on which is most probably unrelated to the JDK version.
I agree. Here's the link: http://aspose.com/file-tools
subject: Using JDK 5 lib with 1.4 application
Similar Threads
Errors while building j2ee project. Help needed urgently.
Upgrading from JDK 1.4 to JDK 5
Calling "winspool.drv" from Java
WASD 5.1.2, JDK 1.4
JDK current version?