图片:
显示版本的命令提示符
错误图片
Hello.java
import java.applet.Applet;
import java.awt.*;
public class Hello extends Applet {
// Java applet to draw "Hello World"
public void paint (Graphics page) {
page.drawString ("Hello World!", 50, 50);
}
}
Hello.html
<HTML>
<HEAD>
<TITLE>HelloWorld Applet</TITLE>
</HEAD>
<BODY>
<APPLET CODE="Hello.class" WIDTH=300 HEIGHT=150>
</APPLET>
</BODY>
</HTML>
错误
Hello : Unsupported major.minor version 52.0
可能是什么问题?
请使用JDK 1.7.0版本,而不是JDK 1.8.0版本。
为了确保这一点,您需要删除计算机上的JDK 1.8.0。
如果使用Mac,则需要删除:
/ Library / Java / JavaVirtualMachines jdk / / jdk。
/ Library / PreferencePanes / JavaControlPanel prefPane。
/library/Internet plug-ins/JavaAppletPlugin.plugin
然后,您需要重新安装JDK 1.7.0,您将成功生成.jar文件。
您必须使用相同版本的Java运行和编译应用程序。
如果你正在使用Eclipse,你应该做两件事:
In Eclipse, click on "Window > Preferences", and in the window that appears, on the left side, under "Java", click on "Installed JREs", click on "Add..." and navigate to the folder that contains the JDK.
Right-click on your project and click on "Properties", in the window that appears, on the left side, click on "Java Compiler" and uncheck "Use compliance from execution environment on the Java Build Path", this allows you to choose in the the list "Compiler compilance level" the same version that you set in the previous step.