1

I am facing an strange issue. I developed java web app in java 6 and when I hosted it on server, its shows error since its java 5 server. I have used annotations, hibernate, rest API in my code and now I want to transform my code with java 5 environment.

is it possible to do so? if yes HOW? Or is there any other workaround for this problem? Please let me know.

@all: This is the error i am getting:

alt text

3
  • annotations are there with java since 5, post stacktrace Commented Dec 27, 2010 at 9:24
  • Are you sure your program works in Java 6? if so, upgrade your server to Java 6, Java 5.0 is EOL. Or get you code to work in Java 5.0. Or install a new server which is Java 6 and leave your old server as it is (perhaps there is a reason you cannot upgrade it) Commented Dec 27, 2010 at 9:25
  • too generic question. post the error Commented Dec 27, 2010 at 9:26

4 Answers 4

1

I am not sure what your build process is but you need to compile your code for a specific target like java 1.5.

  • If you are using javac from the command line look at the -target switch
  • If you are using ant then look at the target property.

You will run into problems if you are using java 1.6 specific libraries. You will know this when you try and run your code/webapp.

I hope this helps.

Sign up to request clarification or add additional context in comments.

2 Comments

what are those java 1.6 specific libraries? can u list a few coz i m not sure if i m using them. I have never used jdk 5 before.
You should check the release notes to see differences between 5 & 6 (oracle.com/technetwork/java/javase/index-140291.html). For third party libraries they should have documentation for the required version, or separate distributions for the different platforms.
0

You'll have to look at the individual errors and figure out what is missing.

The JPA annotations were already part of Java EE 5, so if "hibernate" is causing problems, it either means you are not in fact running on Java EE 5, or you're using hibernate-specific annotations. The REST annotations were indeed added in Java EE 6, but can be used in a Java EE 5 environment relatively easily by adding a JAR with the API as well as the implementation (e.g. Apache Jersey) to the app's class path.

BTW, there's some confusion here concerning Java SE vs. Java EE. You're clearly talking about Java EE features, but there is a big difference between Java SE (which most people think about when you just say "Java") and Java EE.

Comments

0

From your post, it seems you're using Java EE 6 features in a Java EE 5 environment. If your app. server doesn't support such features at its core level, such as sing Servlet 3.0 features in a Servlet 2.5 environment, then you're out of luck.

However, when using features that are libraries, like Hibernate, you can get away using it in a Java EE 5 environment.

Java 6 as a language remains the same as Java 5, however, libraries have changed. Likewise, using JRE classes and methods that are in 6, won't work in 5.

Update: from your screenshot, I see that you're using Java 6 compiled classes on an older version of Tomcat. Compile them for Java 5.

Comments

0

You are trying to run classes compiled against Java 6 on Java 5 (Tomcat 5.x uses Java 5).

  1. You can upgrade to Java 6.
  2. You can compile the classes to be Java 5 compatible by using "-target" argument to javac but this option is not going to help as the problem is occuring with the servlet api. JEE6 requires Java 6.

2 Comments

Yes I know that. Is there a way to do it so that I dont come across that error?
see this is the problem: I made the app with jdk 6. The hosting server wants jdk 5. So should I install jdk 1.5 and then build my app? I am using eclipse IDE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.