我在 Eclipse 中制作了一个 Java applet 游戏,它有很多相关的类和媒体。我现在一直在尝试最终在浏览器中测试游戏,但我很难让它运行。
我导出了一个 .jar 文件(一个不可运行的文件,这会是个问题吗?)并尝试了许多不同的方式来加载小程序。 oracle网站上的资料我也看了一遍。
我的前两个基本问题是:
- 我的小程序没有
static void main(String args[]){
行,因为我的印象是小程序使用init()
和start()
方法。这可能是问题所在吗?
如果没有,我的包含 init 和 start 以及其他基本方法的类称为Start.class
并且位于bin/
目录中。我是否能够编辑包含在从 eclipse 导出的 .jar 中的 list ,但是这个Start.class
作为主类使用Main-Class: Game.Start
? - 另一个非常基本的问题也是关于 java 中的目录或特别是 .jar 存档中的目录,路径名中的文件夹是否总是由
.
分隔?或者/
的工作也一样吗?
我的项目名称只是 Game,我有一个包含 .java 文件的 src
文件夹和一个包含 .class 的 bin
文件夹 我如何将 list 指向 bin/start.class
文件?
抱歉,这让我很沮丧,尤其是因为我真的很想分享这个小程序。任何帮助将不胜感激。
最佳答案
1) My applet does not have a
static void main (args[]){
line because I was under the impression that for applets you use ainit()
andstart()
method. Could this be the problem?
不,这不是问题,因为 Applet 和 JApplet 不使用 main 方法来运行。请注意,有些可能具有主要方法,可用于允许编码人员在非小程序环境中测试代码,但当作为小程序运行时,主要方法将被忽略。
2) Another very basic question also when it comes to directories in Java or specifically in .jar archives, are folders in a path names always separated by a "."? or do "/"'s work too?
jar 文件中的目录使用“/”。请检查您是否试图将资源用作文件,因为 jar 文件不保存文件(而是保存资源)。
My project name is simply Game, I have a src folder with .java files and a bin folder with .class how do I direct the manifest to the bin/start.class file?
考虑显示您的 jar 文件的结构以及您尝试运行 applet 的小型测试 html 文件。
关于java - 在浏览器中运行 Eclipse 制作的小程序时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11172473/