I've compiled war project with Java 1.8, where I've left by accident one unused lib that is part of Java 1.8 .. all other libs belongs to Java 1.7.
Can someone tell me does this have impact if I run this war with Java 1.7?
AFAIK importing statement will not load the class, that will happens by the class loader when you do some operation on that class.
Snipet:
import java.util.stream.Collectors;
public class Test {
public static void main(String[] args) {
//testArrayList.stream().collect(Collectors.joining(","));
}
}
If you will try to run a jar on lower java version which is compiled with a higher version of java.
Then you will get the error at the time of running the java with java command.
java.lang.UnsupportedClassVersionError: Unsupported major.minor version
The version number shown describes the version of the JRE the class file is compatible with.
The reported major numbers are:
Java SE 10 = 54,
Java SE 9 = 53,
Java SE 8 = 52,
Java SE 7 = 51,
Java SE 6.0 = 50,
Java SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45
(Source: Wikipedia)
To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions.
For example, in order to generate class files compatible with Java 1.4, use the following command line:
javac -target 1.4 HelloWorld.java