简体   繁体   English

从 netbeans 运行 java 小程序?

[英]Running a java applet from netbeans?

I am trying to run a Java applet from NetBeans, and in trying to run it, I get a 'main class not found' error.我正在尝试从 NetBeans 运行 Java 小程序,并且在尝试运行它时,出现“未找到主 class”错误。 I can avoid this by doing SHIFT+F6, but that'll only work if I am currently writing in the main class.我可以通过执行 SHIFT+F6 来避免这种情况,但这只有在我当前正在编写主要 class 时才有效。 I will be working on a somewhat large project, and it's going to have multiple files, and eventually it will be quite cumbersome to always navigate back to the main class to the 'main' file and run it from there.我将从事一个有点大的项目,它会有多个文件,最终总是导航回主 class 到“主”文件并从那里运行它会很麻烦。 Is there any sort of configurations I can edit to tell NetBeans that I want to run my project (not the individual file) as an applet?我可以编辑任何类型的配置来告诉 NetBeans 我想将我的项目(而不是单个文件)作为小程序运行吗? I have NetBeans set up from this tutorial .我从本教程中设置了 NetBeans。

In netbeans, right click on the project and chose properties.在 netbeans 中,右键单击项目并选择属性。 Under Application > Webstart, there is an option Applet class.在 Application > Webstart 下,有一个选项 Applet class。 specify the full path to your main class (ie with package names).指定主 class 的完整路径(即使用 package 名称)。

Step 1:步骤1:

步骤1

Step 2:第2步:

第2步

Press Shift + F6 to run applet.Shift + F6运行小程序。

This are the <applet> parameters that worked for me:这是对我有用的<applet>参数:

<applet codebase="../../build/classes/" code="_package_/_JApplet_.class" width="500" height="500></applet>

*Replace _package_ and _JApplet_ with your package and applet class. *用您的 package 和小程序 class 替换_package__JApplet_

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM