如何在java中调exe程序,如何在java中创建exe文件

Hi I want to create an exe file for my java app.

I tried with some third party softwares JEXECreator, successfully created the exe file and its working fine in my system, when I tried with another machine, it’s not working. I got the following error

* The error occurred while running the application. The exit code is 0x10000223.

* Contact the vendor of the application for troubleshooting.

java.lang.ClassNotFoundException: com.sample.SampleMain

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Unknown Source)

at com.ucware.JEXEClassLoader.run(Unknown Source)

at com.ucware.JEXEClassLoader.main(Unknown Source)

**************************************

I know there is something wrong with the classpath which I set.

Actually I want to create the exe file myself without using any third party software.

I found the steps in lot of sites

Created the manifest file named Sample.mft with following contents

Manifest-Version: 1.0

Main-Class:

Class-path:

In this I have some doubts,

How the Main-Class should be added, with the full package name (com.sample.SampleMain) or the class name alone (SampleMain) or with the extension (SampleMain.class)

How the class-path should be added, I have 4 java classes and 2 jars in my project. How to add all these in the class path, and do I need to add the java jdk in classpath.

Where the manifest file should be saved

What should be the manifest file extension (mf or mft)

In command prompt from which directory I should create the exe file (from my project folder or src folder or the folder which contains all the java classes)

What’s the syntax should be used while creating jar in command prompt

(jar cmf Sample.mf Sample.jar Sample1.class Sample2.class Sample3.class Sample4.class jar1.jar jar2.jar) like this or (jar cvfm Sample.jar sample.mf *.class)

When I did something like this I am getting a jar instead of exe file, When I run the jar in command prompt using "java -jar sample.jar" then I am getting class not found exception".

Actually how to create an exe file instead of jar file, that means just by double clicking that exe file, should run my app in any machine.

Can anyone help me to do this?

Thanks in advance.

解决方案

I use the Ant tool under Eclipse IDE to work with InnoSetup and Launch4J to create the EXE and its installer which it also manages the classpath...

A guide? You can refer to:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值