Tomcat 7.x and code compiled on JDK 1.5 - java

From this link looks like minimal Java version supported by Tomcat 7.x is 1.6 but maybe somebody try to check this requirement and use inside webapp jars compiled on JDK 1.5?
Is it works? Or not works at all? Maybe works with limitations?
Thanks in advance.

I'm not quite sure I understand what you mean with "use inside webapp jars compiled on JDK 1.5". But it seems you mix up two things:
To run Tomcat 7.x, you'll need at least JRE or JDK 1.6.
However, you can use any JAR file, which was originally compiled for an earlier Java version as they are upwards compatible.
So if you're interested in using some older jar file, there's no problem.

Related

Which Eclipse version is compatible with Tomcat 10, or do I go back to Tomcat 9?

I'm starting a web development project with a new install of Eclipse for Web developers; I installed Eclipse 2020-06 and Tomcat 10. But evidently those are not compatible; the first example JSP I entered has an error saying that HTTPServlet is not on the path.
On looking further, I discovered that the servlet library pathnames have changed; used to be javax... and are now jakarta... I'm assuming that's the problem, though I don't have definite confirmation of that.
Should I be using a newer version of eclipse, or an older version of Tomcat? Or is there something else I should be using?
EDIT: also using Java 11.0
EDIT: version of eclipse was a typo -- 2022-06 is the actual version.
So, you are assuming right...
There is a change in package name for tomcat 9 to tomcat 10 from javax.* to jakarta.* respectively....
for your project to work,
Either you downgrade to tomcat 9 and keep using the same package (javax)
Or you change change the package name to use jakarta and keep using tomcat 10...
Update to Eclipse 2022-06. It works with both versions, largely automatically.

The type java.util.Comparator cannot be resolved

The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files
I recently installed Java 8. While executing an application, I got above mentioned error can you please help me.
I am using:
Java - jdk1.8.0_51
Tomcat - apache-tomcat-5.5.26
Assuming you are using some IDE, like Eclipse. When you are using jdk 1.8 with IDE, you need to update your IDE to support version 1.8.
It does not matter you are using new jdk's feature or not, but compiler has to load new JRE files in order to compile your project.
If you are using IntelliJ, go to:
File/Settings/Build, Execution, Deployment/Compiler/Java Compiler
and make sure "Use compiler" and "Project bytecode version" have the right configuration.
I had this same error and tried many things to fix it, but finally worked was remarkably simple: It turns that I was simply using an older version of Eclipse that did not support a "Compliance Level" setting of Java that was as high as my JRE. I merely upgraded to a newer version and the problem went away.
From what I understand about "Compliance Level", it's the version of Java that your program is supposed to work on. That much I found out from reading stuff on the net. But what the other solutions did not mention is that your IDE has to be able to be set to a level as high as your JRE. In my case, I was using JRE 1.8, but the highest compliance level my older IDE supported was 1.6.
IMO, this situation should have been flagged as an error by Eclipse. But as it was, I wasted two nights trying to figure this out.
Your project build path could be referring to a jre instead of JDK.
Go to your build path. (In eclipse right click and choose build path).
Go to your libraries and replace the jre with the jdk.
pom.xml version is 1.6?
If this is the way,you would replace jdk1.8 with jdk1.6 ,and environment variable into jdk1.6。
Same strange problem occurred. It turned out that wrong jdk version was in JAVA_HOME
There you are I had the same issue but moment I saw your question i got it fixed. problem is you are not using old version since there is mismatch of referencing with new version. this error will come.
Work around:
1. Change your java version to old.(In my case I had to change to 7)
2. Update each libray and jar file compatible to java 8 that way it will refer java not class file
Here is the image of environment variable in my problem
check if build path is set to run with JDK. It is important point that JKD is software development kit while JRE is a runtime env. Advice who had this problem see the different between JDK, JRE and JVM. https://www.guru99.com/difference-between-jdk-jre-jvm.html

Running java application on different JDK from original

I have developed a Java Application in Eclipse using JDK 1.7.0, the application runs and everything works as expected.
Now I would like to send the application to a colleague of mine who is using a different version of the JDK. He is using 1.6.x.
I am not interested in him opening up the application and debugging through it in Eclipse. I would only like him to run it. If I make a runnable .jar of the application and send that to him, would it work even though he has a different JDK installed on his machine?
Thank You.
You need to compile it using JDK 1.6 (or lower). Provided your code doesn't use features from Java 7, you won't have to change anything in your sources
It would work if your colleague had a newer JRE than the JDK you used to compile it. All versions of JRE are backwards-compatible with all class files built with previous versions, but the opposite can clearly not work because new versions introduce new features. Your colleague will get an UnsupportedClassVersionError.
However, it is easy to set up in Eclipse the target class version for your project: go to Project Properties, Java Compiler, and under JDK Compliance choose the version 1.6.
Needless to say, this will fail if your source code uses any features or library calls which the version 6 does not support.

JDK version problem

I am looking for clarification in jdk versions.
I am getting error
java.lang.UnsupportedClassVersionError:Bad version number in .class file"
I hope this error is for different jdk version. I am having myeclipse6.0.1 and weblogic10.3.
Now, in my systems has jdk1.5 but weblogic has jdk1.6, as well myeclipse supporting 1.5 only.
I read the all forums and they said compile is different version and running different version.
So, here i thought program compliling 1.5 and running 1.6.
Is it correct ?
This means that the Java program was compiled for a newer version of Java than you are trying to run it with.
The easiest way to be certain is to use the same version of Java for compiling and building as is to be used on the final system. For you, this is most likely Java 5.

bad version in class file

When I use certain jars in one of the connector projects i write for lombardi in TeamWorks eclipse i get a bad class version exception...
any ideas how this might be resolved..
Regards,
Adhir
You will get this error if you are using (say) Java 1.5 and you are using a JAR compiled with Java 1.6.
The easiest way to resolve is to upgrade your version of Java to the one used by the JAR.
Try to compile/recompile all your stuff with the same compiler.
Typically this happens when you have something compiled with a higher version and
you try to run it with an older one.
This problem can also be caused by an expired (365-day) Android certificate referenced by Eclipse.
See "Debug certificate expired" error in Eclipse Android plugins for details.
This is a result of running code compiled with a compiler version that is greater than the version of java you are using to run it. IE Code compiled with 1.6 and you are running it with 1.5. See this post to determine what version it was compiled with.
how-can-i-find-the-target-java-version-for-a-compiled-class
the easiest fix is to run it with the most recent JVM.
Root Cause for this error is that: jars including in your project is complied from other version of java and you are compiling your project from other version of java simply upgrading version of java will resolve this problem.
I also faced the same problem.

Categories