Pregunta

Generally, I noticed that when my application's jar was compiled in a java version and running in some other java version the I get java.lang.UnsupportedClassVersionError exception.

But my application uses jars of log4j and tomcat etc...

  1. Use any version of java why don't I get such exception?
  2. Is it possible to make my application's jar to behave same way?
¿Fue útil?

Solución

This exception is thrown if JVM does not support class version you sent it, i.e. if at least one of your classes is compiled by compiler of higher version that version of you JVM.

So, check it. Is there a chance that you compile your classes with compiler of version 1.7 and run them on 1.6?

I believe that log4j and tomcat should not cause problem because I think that they still are compiled for jvm 1.6. Take a look on command line option -target that allows generating classes of specific version even if compiler's version is higher.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top