Here we use
Http://blog.csdn.net/oscar999/article/details/7305489
Jdbctest. Java source file in
1. Use the compilation command in JDK to compile the. Class file.
"C:\Program Files\Java\jdk1.6.0_24\bin\javac.exe" -cp ojdbc14.jar; JDBCTest.java
2. Run the Java command in jdk1.5.
"C:\Program Files\Java\jdk1.5.0_14\bin\java.exe" -cp ojdbc14.jar; JDBCTest
The following error occurs,
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
It seems that Java cannot be compiled in a later version.
On the contrary, if you compile in a lower version, can you run it in a later version?
After testing, you can.
Add javac and Java import lib
Sometimes in order to test something, we use javac and Java commands to compile and run the test class we temporarily wrote. What if other jar packages are used for this test class? We can use the-classpath or-CP parameter to import these required packages.
Assume that the test Class F: \ test. Java is used, and the Lib used is c: \ ABC. jar and D: \ EFG. Jar respectively. So we can write the compilation and running commands in this way.
Javac-CP c: \ ABC. jar; D: \ EFG. jar; F: \ test. Java
Java-CP c: \ ABC. jar; D: \ EFG. jar; F: \ test
Note: The last one. The class and Lib package must be separated by spaces. If it is in Linux, replace; with: the path must also be replaced with the Linux format.