创建并运行Jar文件 [英] Creating and running a Jar file
问题描述
我是java编程中的初学者。我创建了一个名为 Comp Project 的包,其中包含两个类....
I am a beginner in java programming. I have created a package called Comp Project which contains two classes....
- ATM: 它具有执行atm屏幕操作的各种功能。
- Main:此类调用 ATM 并执行它们。
- ATM: It has various functions to carry out actions of atm screen.
- Main: This class calls all the functions from ATM and executes them.
现在程序运行正常,我必须创建一个jar文件。
我创建了一个Jar文件,主类被选为 Main 。但是当我尝试运行它时......它不起作用。问题是,我不明白创建清单是什么...我看了其他帖子,但我什么都不懂。
Now the program is running good and I have to create a jar file. I created a Jar file with the main class selected as Main. But when I try to run it....it doesn't work. The problem is that i don't understand what creating a manifest is...I looked onto other posts but i did not understand anything.
有谁可以告诉我创建一个合适的Jar文件和运行的步骤?我需要两个,因为我不知道我哪里出错。
Can anyone tell me the steps to follow for creating a proper Jar file and Running it?? I need both as I don't know where i am going wrong.
更新:我正在使用BlueJ。
Update: I am using BlueJ.
推荐答案
你可以使用 jar cf yourCompAppJar.jar Main.class
来创建你的jar文件,如果你有JDK 6就可以使用 cfe 指定入口点。
You can use jar cf yourCompAppJar.jar Main.class
to create your jar file, if you have JDK 6 you can use the cfe to specify the entry point.
如果您使用的是Eclipse:
If you are using Eclipse :
- 右键单击项目> 单击导出> 选择Java文件夹下的Runnable JAR文件> 在启动配置中选择班级名称> 选择保存罐子的位置> 完成。
- Right-click the project > click Export > select "Runnable JAR file" under the Java folder > In the launch configuration select the class name > choose where to save your jar > finish.
这篇关于创建并运行Jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!