This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Converting simple app from 1.5 jdk to 1.4.2 jdk Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Converting simple app from 1.5 jdk to 1.4.2 jdk" Watch "Converting simple app from 1.5 jdk to 1.4.2 jdk" New topic

Converting simple app from 1.5 jdk to 1.4.2 jdk

Katie Doody
Ranch Hand

Joined: Nov 03, 2006
Posts: 90
I am having some issues coverting my application from 1.5 jdk to 1.4.2. I need to back down the version because it is going to run on a SAP box which they do not want to change at all. I am not sure how to do this. Is it as simple as downloading 1.4.2 and compiling it? I have compiled it on netbeans and have to move it to the SAP machine (Linux) Any help would be appreciated. Thanks.
[ August 10, 2007: Message edited by: Katie Doody ]
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

I believe that you could continue to use the 5.0 JDK and use a preference to compile it for 1.4.2. (I don't know for sure about NetBeans, but I believe that this is possible in Eclipse).

1. Remove any 5.0 features:
a. Generics
b. enum
c. auto-boxing and auto-unboxing
d. varargs
e. annotations
f. the for-in loop
g. format() and printf() method
h. any new stuff in the API

I think that you should be able to flip the switch to go to 1.4.2 and then handle the compile-time errors as they show up.

[ August 10, 2007: Message edited by: Kaydell Leavitt ]
Katie Doody
Ranch Hand

Joined: Nov 03, 2006
Posts: 90
Thanks for the reply. So I would download the sdk and then compile the applicationn in 1.4.2 platform?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

You wouldn't need to use 1.4.2 to compile; just use the -source 1.4 -target 1.4 switches to the 5.0 compiler (or use whatever options your IDE offers for targeting a particular JDK version.)

But you should definitely test on 1.4, as using the compiler switches won't stop you from unknowingly using an API that's not available in 1.4.

[Jess in Action][AskingGoodQuestions]
Katie Doody
Ranch Hand

Joined: Nov 03, 2006
Posts: 90
Thank you both ..I changed the compile version and it picked up the differences. I have it converted. Good deal.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14601

You could compile on JDK 1.5 with the -source and -target switches as Ernest suggests, but this will not prevent you from using classes that are only in the Java 5 API.

It's safer to download 1.4.2 and compile your program with that. Then at least you will get a compiler error if you are using a class that doesn't exist in Java 1.4.2, instead of a runtime error later on.

Something else you could do is use Retroweaver, which is a tool which makes it possible to run Java 5 code on a Java 1.4.2 JVM.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Converting simple app from 1.5 jdk to 1.4.2 jdk