This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Java in General and the fly likes Incompatible Java Versions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Incompatible Java Versions" Watch "Incompatible Java Versions" New topic

Incompatible Java Versions

Dan McGinn-Combs

Joined: Jul 17, 2011
Posts: 4
I recently started working in an environment which runs Java v1.4.2 on the server and in production. While trying to set up my workstation development environment, I found that I could no longer download Oracle JDK. I need to be able to compile code offline and generate WAR/EAR files to deploy into the test environment (there is no viable dev environment for this).

the most significant piece of code that suffers from 1.4.2 vs. 1.6 disparity is the parsing of time/date formats using SimpleDateFormat:

so, two questions:
  • Is there a compile option that will allow me to use the 1.6 compiler to generate code for a 1.4.2 server? (or where can I find Windows versions of the JDK?)
  • and
  • How can I simply rewrite the date/time arithmetic for 1.4.2?

  • thanks!
    - Dan
    Maneesh Godbole
    Saloon Keeper

    Joined: Jul 26, 2007
    Posts: 10535

    ...or where can I find Windows versions of the JDK?

    Check out the section titled "Java SE 6 Update 26" here
    Clicking on the red JDK button should take you to the download section

    [How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
    Jesper de Jong
    Java Cowboy
    Saloon Keeper

    Joined: Aug 16, 2005
    Posts: 14428

    Java 1.4.2 is so old that you cannot get it easily anymore. This page on Oracle's website explains more: Java 2 Platform, Standard Edition, v 1.4.2.

    Here is the download page for JDK 1.4.2 releases.

    Note that support for Java 1.4.2 is no longer free. You will not get security updates and bug fixes for Java 1.4.2 for free anymore. If your company for some reason doesn't want to upgrade to a newer version, they can purchase business support for Java 1.4.2 from Oracle. It would be better if your company would seriously consider upgrading to at least Java 6.

    Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
    Rob Spoor

    Joined: Oct 27, 2005
    Posts: 19781

    Dan McGinn-Combs wrote:Is there a compile option that will allow me to use the 1.6 compiler to generate code for a 1.4.2 server?

    Use the -source 1.4 and -target 1.4 compiler flags, and make sure that you do not use any class, method or field that was added in Java 5.0 or beyond. If you use any of those you'll get a NoClassDefFoundError, NoSuchMethodError or NoSuchFieldError during runtime.

    If you use Eclipse and have some old 1.4 JRE installed you can setup the 1.4 JRE inside Eclipse and use that for the project; that will help you prevent the usage of newer features. You can also set the compiler version to 1.4 from Eclipse.
    Netbeans probably has similar features but I haven't used Netbeans so I couldn't confirm this.

    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
    How To Ask Questions How To Answer Questions
    Dan McGinn-Combs

    Joined: Jul 17, 2011
    Posts: 4
    thanks for all the pointers... none of them were null!
    - Dan
    It is sorta covered in the JavaRanch Style Guide.
    subject: Incompatible Java Versions