Hello,

I am trying to execute a jar file with higher version of jdk. But it fails & the worst part is I am not getting any error message.

Jar file compiled verison: jdk 1.5
Executed version: jdk 1.7

I assume the jar file is downward compatible. thoughts pls?

Thanks!
Om

Dani AI

Generated

A short expert note on this kind of problem: a JAR compiled against an older Java release normally runs on a newer JVM. When a JAR appears to “do nothing” the root cause is almost always environmental or packaging-related rather than a binary incompatibility from 1.5 -> 1.7.

Common diagnostic checks and quick commands:

java -version
which java        # Windows: where java
echo $CLASSPATH   # Windows: echo %CLASSPATH%
java -jar myapp.jar
java -verbose:class -jar myapp.jar
jar tf myapp.jar

Practical pointers not covered in detail above: confirm the runtime on PATH is the expected JVM; inspect META-INF/MANIFEST.MF to ensure a valid Main-Class (or run the main class explicitly with -cp); remember -jar causes the JVM to use the JAR manifest for its classpath and ignores a global CLASSPATH or a -cp argument for that invocation; use -verbose:class to see which classes and JARs the JVM actually loads. Silent failures can also come from missing native libraries, launch wrappers that use javaw (no console), or security constraints for applets/JSR-56-style deployments.

Good catches by and pointed toward classpath and hidden console issues; those diagnostics above flesh out how to check them systematically so the same problem can be found and fixed more quickly in other environments.

Recommended Answers

All 3 Replies

if you get no error message, how do you know it fails? it might just as well have reached a conditional statement and based on that don't run.
or, you didn't set your classpath right, and your OS doesn't know what to do with your .jar file.

In general a jar will run on any higher jre version. It's possible you may run foul of tighter security settings, as there have been a number of changes there since 1.5.
How exectly does it "fail"? - absolutely nothing happens - runs but wrong results etc?
Did you try running the jar with java.exe (as opposed to the normal javaw.exe) so you can see the console output?

I did not see any java process when I tried to execute the jar.

The issue is fixed now. I have removed the CLASSPATH variable, removed the previously instaaled jdk from Server & installed latest jdk version,set CLASSPATH.

Jar file now runs as expected[I'm seeing expected results]. Thanks stultuske & James for super fast response..

I'm marking this question as "Solved"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.