Jcreator 下怎么生成可执行文件?

paopaokevin 2003-10-16 09:10:40
Jcreator 下怎么生成可执行文件?或者是.bat的
...全文
88 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
paopaokevin 2003-10-18
  • 打赏
  • 举报
回复
本来想用jet的,不过看了半天还是不知道要怎么用。ft~~~
paopaokevin 2003-10-18
  • 打赏
  • 举报
回复
老蒋的方法蛮好用的,不过可能是我的程序有问题,生成后运行的功能有的没了。
anson2003 2003-10-18
  • 打赏
  • 举报
回复
是这样,说错了,少了-:


我说你先把所有文件打成JAR文件包!
jar cmf 生成的JAR文件名.jar c.mft 所有类

其中c.mft文件内容为:
Main-Class: 类名

注意:类名后面要加回车,还有":"后面有个空格。
生成Jar文件打开方式改为javaw.exe来打开!


anson2003 2003-10-18
  • 打赏
  • 举报
回复
我说你先把所有文件打成JAR文件包!
jar cmf 生成的JAR文件名.jar c.mft 所有类

其中c.mft文件内容为:
Main Class: 类名

注意:类名后面要加回车,还有":"后面有个空格。
生成Jar文件打开方式改为javaw.exe来打开!
匪六哥 2003-10-17
  • 打赏
  • 举报
回复
把Java程序编译成本地码


native code compilers
Most compilers generate JVM byte codes. Native Code Compilers will optionally generate native *.exe files. JITs create native code at execute time, but don't create *.exe files. The Microsoft SDK for Java includes a tool called jexegen which turns your .class file(s) into an .exe file. It doesn't compile them or convert them to machine code; it just stuffs the contents of the .class files into the .exe file along with some code to pass those bytecodes to the MS JVM to be interpreted. The resulting exe files need access to the Microsoft JVM to work, unlike true native exe files which are standalone and written in machine code. download it as part of the Microsoft SDK for Java 4. There is a similar product called Java2exe.
Here are seven ways to get what acts like a Java executable file:

1.Use a native compiler. This is the only method that gives you a true machine code executable. You may still have to distribute some DLLs or the JRE along with your executable.

2.Set up a shortcut with the appropriate java.exe command to load the class.

3.Bundle your classes in a jar with the Main-Class attribute. Set up an association for *.jar to make it executable.

4.Write yourself a tiny C program that exec's a Java command to load your class. Assuming the jar file Foo.jar with main class Bar, here how to making a Foo.exe tiny kickoff program. Compile the following program foo.c to foo.exe:

#include <process.h> int main(void) { execlp("java.exe", "java.exe", "-cp", "foo.jar", "Bar", NULL); return 0; }

If you want to play really strange games, concatenate the jar file onto the end of your foo.exe kicker, and put the EXE file on the classpath where you would normally need to place foo.jar. This way you can distribute but a single file, albeit uncompressed. Reputedly java.exe will happily treat this combo as a standard jar. Executing the foo.exe just ignores the jar tacked on the end. e.g. change the foo.c code to read

#include <process.h> int main(void) { execlp("java.exe", "java.exe", "-cp", "foo.exe", "Bar", NULL); return 0; }

then
rename foo.exe littlefoo.exe
copy /b littlefoo.exe + foo.jar foo.exe
You only need distribute foo.exe.

5.Use the InstallAnywhere NOW installer (or other installer). It uses a standard platform-dependent EXE kickoff file for a standard interpreted platform-independent Java application packaged in a jar file.

6.Use Microsoft's Jexegen bundler. It only works with the Microsoft JVM. Webgain Café also works this way as does J2Exe.

7.Distribute using Java Web Start. Users can click on menu or desktop items to kick off pure java Programs.

What are the advantages of a native compiler?

Execution speedVisit any of the vendor sites, such as Jet for independent benchmarks. The improvement is even more marked for old clunker machines that your customers may use. Native compilations tend to me more scalable, doing well as you add more threads. Depending on just what you are doing, you may get over twice the speed of Java 1.4.1 Hotspot.
Load speedA natively compiled program will load and start execution much faster than one using Java 1.4.1 JVM. Customers resent slow load times even more than slow execution times. They have nothing to do but sit there and wait. JITed Java is precluded from many applications because of its extraordinarily slow load time. Natively compiled Java opens the doors to all the traditional C applications.
Self-Contained Distribution PackageJava, or even Java Web Start requires the customer to pre-install the JRE. You are legally not permitted to bundle that JRE with your app. The customer has to go get it for himself. Native apps can be distributed in familiar ways as totally self-contained packages. On the other hand, once Java Web Start is installed, the end user can install new apps with a single click.
Distribution sizeJava class files are quite tiny, but they need the entire JRE to make them work. If the customer has Java already installed, then the class files packed in a jar are exceedingly compact. However, if he does not have Java installed, that then the native distribution will be smaller.
SecurityNative apps, especially optimised apps, are much harder to decompile (reverse engineer).
PrejudiceThe customer need not know your app is written in Java. Some customers are Microsoft fanatics who follow the party line that Java is slow or evil.
Code SharingCompilers like Jet, bundle classes into DLLs. This means if you have two JVMs running, you need only one copy of the DLL in RAM. This makes more efficient use of RAM.
What are the disadvantages of a native compiler:
Single PlatformYour code works on only one platform. Even if you buy a multiplatform compiler, you need to generate different versions, one for each platform, and different install scripts for each platform. It is even more import than ever to test the code on each platform.
CostThe compiler is an extra cost item.
ComplexityDistribution is more complex with DLLs and EXEs and an install script. (Jet comes with an install generator, so you don't necessarily have to buy Installshield or equivalent.)
DLL version hellIn place of the problem of mixed generations of JRE, you have the problem of mixed generations of support DLLs on your client site.
Learning CurveNative compilation is more complex than standard compilation. You need to learn new skills to master it, e.g. dealing with a mixture of static and dynamic class loading. It is quite simple. The only mildly complicated thing is dealing with dynamic class loading.
You can't use native compilers on Applets or Java Web Start Weblets.


Most native code compilers are for Windows, though TowerJ creates native code for various Unices. Supercede has been sold to the Jove people, leaving the floor to Jet, BulletTrain, IBM Visual Age and JBuilder, Excelsior JET, GNU Java Compiler for Linux; Jove, Webgain Café, TowerJ and gcj.
compiler (with table showing how each compiler works), exe, installer, interpreter, jar, J2Exe, Java2exe, NativeJ, Jexegen, JIT, JVM, optimiser, Marco Schmidt's list of native compilers, the Bear Cave list of native compilers


上面的方法有一些是小技巧。当然没有完美的解决方案。但Jet,TowerJ,InstallAnywhere,gcj,exe4j,nativeJ都是可以试试的,只要用户满意就好了。安装包大一点看起来值钱啊,呵呵。
orant 2003-10-17
  • 打赏
  • 举报
回复
Jcreator不能生成可执行文件
只能生成.class文件

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧