在 Unix 命令行中编译并运行 netbeans GUI 应用程序

发布于 2024-11-18 12:34:22 字数 1078 浏览 3 评论 0原文

我需要为我的班级制作一个 GUI 应用程序,所以我想确保我可以使用 GUI 生成器传输 netbeans 项目(我知道如何在没有它的情况下制作它,但这更耗时,我认为如果没有它,它看起来会更整洁)我猜测坐标等,并且我习惯了netbeans GUI构建器)从netbeans到unix并编译它。所以这就是我所做的,我创建了一个名为 StartFrame.java 的新 JFrame 表单(使用 netbeans GUI Builder)和另一个名为 MenuFrame.java 的 JFrame 表单。 (请记住,它在 netbeans 中运行时没有错误) StartFrame 创建 MenuFrame 的新实例并在第一次运行时将其打开。所以我把它全部转移到了unix系统上。所以一开始我尝试编译它,但当然它出错了,说找不到 org.jdesktop...。
好的,我已经在 stackoverflow 和网络上搜索过这个了。所以我最终从 netbeans 的库中获取了 swing-layout-1.0.4.jar。 我对从命令行进行编译有点陌生,但我将它们全部放在同一个文件夹中,并且当我位于该目录中时。 我这样做了

javac StartFrame.java -cp swing-layout-1.0.4.jar

,并且收到了 NoClassDefFoundException: MenuFrame 错误,即使它位于同一文件夹中。然后我尝试了一下

javac StartFrame.java MenuFrame.java -cp swing-layout-1.0.4.jar

,它编译得很好,没有错误。然后它创建了6个文件 StartFrame.class StartFrame$1.class StartFrame$2.class StartFrame$3.class StartFrame$4.class MenuFrame.class 我尝试运行它

java -cp swing-layout-1.0.4.jar StartFrame

,它有一个 NoClassDefFoundException: StartFrame。我在网上搜索了此问题和堆栈溢出的修复程序,发现了类似的(虽然不完全)问题,但没有一个修复它。

I need to make a GUI Application for my class , so I want to make sure I can transfer a netbeans project using the GUI Builder (I know how to make it without it, but that's more time consuming and I think it would look neater without me guessing coordinates etc. and I was use to the netbeans GUI builder) from netbeans onto unix and compile it. So here's what I did I made a new JFrame form (using netbeans GUI Builder) called StartFrame.java and another called MenuFrame.java. (keep in mind that it ran with no errors in netbeans) StartFrame creates a new instance of MenuFrame and opens it on it's first run. So I transferred all of it onto the unix system. So at first I tried compiling it, but of course it got errors, saying that org.jdesktop... isn't found.
Okay so I've already searched stackoverflow and the web for this. So I ended up getting the swing-layout-1.0.4.jar from the libraries in netbeans.
I'm kind of new at compiling from command line, but I put them all in the same folder, and while I was in that directory.
I did

javac StartFrame.java -cp swing-layout-1.0.4.jar

and I got the error that NoClassDefFoundException: MenuFrame even though it is in the same folder. So then I tried

javac StartFrame.java MenuFrame.java -cp swing-layout-1.0.4.jar

and it compiled fine with no errors. So then It created 6 files StartFrame.class StartFrame$1.class StartFrame$2.class StartFrame$3.class StartFrame$4.class MenuFrame.class
I tried running it with

java -cp swing-layout-1.0.4.jar StartFrame

and it had a NoClassDefFoundException: StartFrame. I searched the web for fixes for this and stack overflow and found similar (not exact though) problems like this, but none of those fixed it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚风撩人 2024-11-25 12:34:22

文件 dist/README.TXT 将告诉您如何继续。在命令行中输入 ant -p 以查看可用命令:ant run 通常效果很好。

附录:

机器没有安装ant

这将是不寻常的,所以你一定要验证它。您可能需要将当前目录添加到路径中,例如

java -cp .:swing-layout-1.0.4.jar StartFrame

The file dist/README.TXT will tell you how to proceed. Type ant -p at the command line to see that available commands: ant run is usually good.

Addendum:

The machine doesn't have ant installed

That would be unusual, so you should certainly verify it. You may need to add the current directory to the path, e.g.

java -cp .:swing-layout-1.0.4.jar StartFrame
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文