Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I build in Java1.4 and run on Java1.6

 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I build my web app war file in an environment where java_home is jre1.4.2_06.
I am running the web app with tomcat-4.1.31 on another machine that has java jre1.6.0_01.
I am getting some wierd behavior, and am not sure if maybe I have to build and run using the same java version.
Thanks for any input,
Kim
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15208
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Newer versions of Java should be able to run code from older versions without modifications, so code compiled on Java 1.4 should run on Java 6. It is possible, however, that there are small incompatibilities, see: Java SE 6 - Compatibility.

But maybe the problems that you are getting are not at all caused by the version difference. Please explain what problems / strange things you are seeing, maybe we can help you to find out what the cause is.
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your reply.
Its hard to post the code here because it is long, but in a nutshell, I save some objects into an ArrayList, and put the ArrayList into the session. In another part of the code I get the ArrayList out of the session, and when I try to use it I hit a null pointer exception. The thing that is strange is that I never hit this exception when I have the same war file running on a machine using the older version of java, it only happens with the newer version.
 
Jan Cumps
Bartender
Posts: 2584
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that particular error is Java versions related.
Regards, Jan
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15208
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll just have to debug your software on the new Java version (where you can reproduce the problem). Add log statements in strategic places so that you can follow what the program does, or run your program in a debugger so that you can go through it step by step to see what it does.
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper, very good advice. I was stalling from doing this as my environment has changed greatly since writing this older code. I bit the bullet and did this and was able to fix my problem.

What is strange is that the code did work using our older java but not with the updated java.

It turned out to be a problem in my struts-config.xml file.

You know how in an action you have forwards that are to another action, or to a jsp page? The syntax on my forward to another action was a bit off, and it seems like the older java was OK with it, but the newer one did not "like" the syntax. Instead of throwing an error though, it appears that struts just kept revisiting the same original action over and over in a loop. Very wierd!

A bit more detail if people are intersted :
typical forward to a jsp :

typical forward to another action:


Well, I combined the two, I gave a web/jsp path to an action like this :


Thanks for input!

This syntax had worked previously even though it was wrong. Confusing!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic