This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Running program written in Java 6 in JRE 1.4.2 Environment Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Running program written in Java 6 in JRE 1.4.2 Environment" Watch "Running program written in Java 6 in JRE 1.4.2 Environment" New topic
Author

Running program written in Java 6 in JRE 1.4.2 Environment

S tiopea
Greenhorn

Joined: Jun 23, 2009
Posts: 1
Hi everyone,

I wrote a program for a friend of mine to help him out with repeated similar database searches, however he is unable to run this program. I wrote the program in Java 6 (The latest version of Netbeans), but he can only use JRE 1.4.2 due to other programs that he has to use at work.

When he tries to run the JAR file, he is getting an error that says: “Could not find main class. Program will exit.”

I rebuilt the program making sure that main was selected as the default class and the program runs perfectly on other computers (all of which have the latest verison of Java on them), but it still does not work for him. I am assuming that him running 1.4.2 is the problem since it works fine in other places and the main class was set as default.

Any ideas on how to fix this so that he can run it?


Thanks!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16695
    
  19

Any ideas on how to fix this so that he can run it?


Java is not forward compatible. You will have to recompile your program for Java 1.4.2. And of course, this also mean that you can't use any feature or API that doesn't exist in Java 1.4.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Henry Wong wrote:
Any ideas on how to fix this so that he can run it?


Java is not forward compatible. You will have to recompile your program for Java 1.4.2. And of course, this also mean that you can't use any feature or API that doesn't exist in Java 1.4.

Henry


hmmm Seems kind of odd that the OP's friend would restricted to an older version of the JRE because of backwards compatibility problems. Is that unusual? Of course, when your computer is owned by the company that employs you, then you have to play by the rules.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

AFAIK retroweaver only does 1.5=>1.4 (same with retrotranslator), although it might still work... but it *is* possible to "backport" binaries.

Depending on the app you might also need concurrent-utils.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3036
    
    4

Fred Hamilton wrote:Seems kind of odd that the OP's friend would restricted to an older version of the JRE because of backwards compatibility problems. Is that unusual?


It is not so unusual. A lot of times code written to Java 1.4 may have specific work-arounds for bugs or behaviors in Java 1.4. Then Java 5 comes along and fixes the bug or changes the behavior and the application doesn't work the same. It is often hard to predict what the differences between versions will mean, but specifically between Java 1.4 -> 5 there was a lot of changes with the memory model. So the easiest thing to do is tell people that they only can use this one version of Java which the program was coded and verified on.

Another solution is to package a Java 6 Run Time with the application and use a batch file which launches the application with the target JRE.


I am not sure how much of the JRE install you actually have to copy. Maybe all maybe not. Your batch file / script could call something like:

Perhaps with some fooling around with the classpath if you need to add libraries etc... You could also probably have the script check the installed Java Run Time, and if it isn't 6+ then use the included one, otherwise use the built-in one.

As a note, I haven't actually ever done this myself, so it is all conjecture. But I have run applications that do this, like ImageJ for example.


Steve
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Running program written in Java 6 in JRE 1.4.2 Environment
 
Similar Threads
Starting JBoss
executing class without main()
In contrast to MS Windows, JVM ....
Java JDK Installation Problem - Need Help!
jre in sdk does not work