I am trying to compile the HelloWorld class as a test, and it shows an error that I do not know how to solve. This seems to be a bit of an incompatible version, but when I do java -versionand javac -versionyou show 1.8.0_73.
Here is what I am trying to compile:
String arquivo2 = "/C:/classes/HelloWorld.java";
PrintWriter saida = new PrintWriter(new FileWriter("logCompilacao.txt"));
int resultadoCompilacao = com.sun.tools.javac.Main.compile(new String[]{arquivo2},saida);
But this is the conclusion:
/C:/classes/HelloWorld.java:2: cannot access java.lang.Object
bad class file: C:\Program Files\Java\jre1.8.0_73\lib\rt.jar(java/lang/Object.class)
class file has wrong version 52.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
public class HelloWorld {
^
1 error
"class file has invalid version 52.0, must be 49.0." Does anyone know how to solve this problem? I tried a lot, but I did not know how to solve it.
source
share