java打包程序
❶ 怎样将java写的程序打包成exe文件
java的工具软件一般开源,你可以到/上找到你喜欢任意一个打包工具,它的分类就叫“打包工具”这里推荐一款叫做JSmooth的,它的打包效果在我的应用过程中是比较出色的。在使用中需要注意的有几点:第一:如果需要不安装jre就可以运行的话,你需要在打包的过程中将jre一起打包进exe文件。第二:记得打包后的程序只能应用在windows下,原因如下:第一你把它打包成exe是windows的应用程序格式,第二就是一起打包的jre也是windows版本。第三:打包程序中不能包含servlet等需要容器管理的部分,比如你在tomcat中可以使用的一些东西。所以建议你选择jdbc操作数据库,而不要使用tomcat等容器的数据库连接池。第四:即使打包了也需要注意包和类之间的路径关系,在打包后无法使用配置文件或者xml进行设置和扩展,所以你只能将一些配置型的信息直接卸载程序中。第五:打包后绝不可能支持接口扩展,除非你重新打包。具体使用方法很简单,稍微查查字典应该就可以了,只有几个重要的选项:比如二进制文件指的是exe文件jre指的是java运行环境或是虚拟机,或者也有人称之为运行时
❷ 如何把java程序打包成exe
工具/原料
jar转exe转换器
java程序
方法步骤
1、下载jar转exe转换器,双击运行
❸ 怎样将编译好的java程序打包成可执行文件
需要的工具myeclipse 、jar2exe
步骤:1、将Java项目导出成.jar包,鼠标右键项目名,选择导出
❹ 如何把java程序打包成exe
将java源码打包成exe的步骤如下:1、最简单直接的方法,选择想打包的程序,右键export;2、选择Java选项,再选择RunnableJARfile选项,点击next按钮;3、选择程序的主类,还有Main函数的类和输入要导出的位置,点击finish;4、在电脑上,设置好Jar文件的打开方式(别默认用解压缩的工具打开就行),双击即可运行。
❺ JAVA程序怎样打包
第一:普通类导出jar包,我说的普通类就是指此类包含main方法,并且没有用到别的jar包。
1.在eclipse中选择你要导出的类或者package,右击,选择Export子选项;
2.在弹出的对话框中,选择java文件---选择JAR file,单击next;
3.在JAR file后面的文本框中选择你要生成的jar包的位置以及名字,注意在Export generated class files and resources和Export java source files and resources前面打上勾,单击next;
4.单击两次next按钮,到达JAR Manifest Specification。注意在最底下的Main class后面的文本框中选择你的jar包的入口类。单击Finish,完成。
你可以在dos环境下,进入你的jar所在的目录,运行 java -jar 名字.jar,检测运行是否正确。
第二、你所要导出的类里边用到了别的jar包。比如说你写的类连接了数据库,用到数据库驱动包oracl.jar.。
1.先把你要导出的类按照上面的步骤导出形成jar包,比如叫test.jar
2.新建一个文件夹main,比如在D盘根目录下;
3.把test.jar和oracl.jar拷贝到main文件下,右击test.jar,解压到当前文件夹。把META-INF\MANIFEST.MF剪切到另外一个地方 (比如是桌面!) ;
4.右击oracl.jar,解压到当前文件夹。
5.在dos环境下,进入到D盘的main文件夹下,执行 jar cvfm new.jar meta-inf/manifest.mf .,不要忘了最后面的点。
6.用压缩工具打开你新生成的new.jar,用你放在桌面的META-INF\MANIFEST.MF覆盖new.jar原有。
你可以在dos环境下,进入你的jar所在的目录,运行 java -jar 名字.jar,检测运行是否正确。
❻ java程序如何打包成apk
首先下载eclipse与android插件,安装完毕后,建立android项目,编码完成后,生成keystore,使用jdk自带的keytoo l-genkey -aliasandroid.keystore -keyalg RSA -validity 100000 -eystore android.keystorex0dx0ax0dx0a然后选择要打包的项目,右键点击_>Androidtools_>Export Signed Application Package,选择哪个项目,下一步后,选择刚才生成的那个key和生成时录入的密码,下一步设置输出位置。x0dx0a完成APK生成。x0dx0ax0dx0aWEB项目不可能生成APK ,如果你现有项目可以把相关的源码文件复制到新建的android项目内,但是lib包有可能不支持,要看你用了那里lib。
❼ 怎样将java程序打包成安装文件
一,下载inno setup
二,下载jre..去java官方下载
.这个是我将要打包的目录(netbeans编译后的dist文件夹)
然后把jre和相关的东东放进去,然后在里面加入一个go.cmd(bat)(名字随意啦)
Java代码
@echo off
echo 请稍后..安装Java运行环境ing
'如果没有java命令 则安装jre
java||jre-6u20-windows-i586.exe /q /norestart
start /MIN javaw -jar AutoCheckOut.jar
代码就像这样
解释下这里..
java||jre-6u20-windows-i586.exe /q /norestart
意思是..如果java这个命令执行不成功..则执行后面那句jre-6u20-windows-i586.exe /q /norestart
这句话是在安静模式下安装jre,没有对话框
这部完成后
start /MIN javaw -jar AutoCheckOut.jar
可以让我们的java程序在一个没有控制台的方式运行
然后你的目录大概就是这样的
好了.改下一步了
四,用inno创建setup.exe
打开inno
用向导创建
之后一步一步到这里
注意添加文件和文件夹 你添加的部分都是作为应用程序的根目录
这里改成我们刚才写的cmd(bat)文件
然后继续向前.按照你的喜好来改设置
最后到这里的时候
我们还要改小小的地方..不然的话..
1.[Files]里面
Source: "E:\JAVA\AutoCheckOut\dist\lib\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
这一行 可以看到吧lib目录加到根目录区了..所以要改一下
Source: "E:\JAVA\AutoCheckOut\dist\lib\*"; DestDir: "{app}\lib\"; Flags: ignoreversion recursesubdirs createallsubdirs
2.[Icons]里面
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
需要多加一行
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";WorkingDir: "{app}"
加这行是为了让cmd运行时有正常的工作目录
❽ 如何把java程序打包成.jar
打包成一般的jar包的步骤如下:
1.输入如下命令即可:
Cmd代码
jar
cvf
counter.jar
-C
bin
.
其中,“-C
bin”实际上是告诉jar命令先cd到bin目录下,再在此目录执行没有参数“-C
bin”的命令,等价于:
2.Cmd代码
cd
bin
jar
cvf
counter.jar
.
//
"."代表当前路径
❾ 如何将一个java应用程序打包成.exe
1.以netbeans 7.1.1中的java项目为例,启动netbeans 7.1.1,并在里面打开自己需要打包成exe的java项目
2.选中该项目,调试确保通过无错误之后,点击工具栏上面的“清理并生成”按钮
很快netbeans就能为我们生成一个jar的包了,具体路径可以查看输出窗口获得。一般是位于项目文件夹的dist目录下,记住这个jar文件的所在位置
❿ java如何打包
建议使用ANT打包工具,下载地址:http://apache.justdn.org/ant/binaries/apache-ant-1.6.5-bin.zip
此工具用java编写,跨平台,能实现很多功能:编译、打包、运行、文件操作、数据库操作、自定义任务等。
主要使用方法:在工程目录下编写build.xml配置文件,然后运行ant即可:
#ant
或
#java -jar ant.jar
下面给你提供一个例子,是jakarta-oro-2.0.8的包的build.xml
<?xml version="1.0"?>
<project default="jar">
<!-- Allow properties following these statements to be overridden -->
<!-- Note that all of these don't have to exist. They've just been defined
incase they are used. -->
<property file="build.properties"/>
<!--
<property file=".ant.properties"/>
<property file="${user.home}/.ant.properties"/>
<property file="default.properties"/>
-->
<!-- prepare target. Creates build directories. -->
<target name="splash">
<splash imageurl="./ant_logo_medium.gif"/>
</target>
<target name="prepare" depends="splash" description="Creates build directories.">
<tstamp>
<format property="DATE" pattern="yyyy-MM-dd hh:mm:ss" />
</tstamp>
<mkdir dir="${build.dest}"/>
<mkdir dir="${build.dest}/META-INF"/>
< todir="${build.dest}/META-INF">
<fileset dir="${top.dir}">
<include name="LICENSE"/>
</fileset>
</>
<mkdir dir="${build.tests}"/>
<available file="${jakarta-site2.dir}/lib" type="dir"
property="AnakiaTask.present"/>
</target>
<target name="prepare-error" depends="prepare"
description="Prints error message for prepare target."
unless="AnakiaTask.present">
<echo>
AnakiaTask is not present! Please check to make sure that
velocity.jar is in your classpath.
</echo>
</target>
<!-- lib target. Compiles the library classes only -->
<target name="lib" depends="prepare"
description="Compiles the library classes only.">
<javac srcdir="${build.src}"
destdir="${build.dest}"
excludes="examples/**,tools/**"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
</target>
<!-- examples target. Compiles the example classes. -->
<target name="examples" depends="prepare,lib"
description="Compiles the example classes.">
<javac srcdir="${build.src}"
destdir="${build.dest}"
includes="examples/**"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
</target>
<!-- tools target. Compiles the tool classes. -->
<target name="tools" depends="prepare,lib"
description="Compiles the tool classes.">
<javac srcdir="${build.src}"
destdir="${build.dest}"
includes="tools/**"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
</target>
<!-- tests target. Compiles and runs the unit tests. -->
<target name="tests" depends="prepare,lib"
description="Compiles and runs the unit tests.">
<javac srcdir="${build.src}/tests"
destdir="${build.tests}"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
</target>
<!-- jar target. Compiles the source directory and creates a .jar file -->
<target name="jar" depends="lib" description="Compiles the source directory and creates a .jar file.">
<jar jarfile="${top.dir}/${final.name}.jar"
basedir="${build.dest}"
includes="org/**,META-INF/**"
excludes="**/package.html,**/overview.html">
<manifest>
<section name="org/apache/oro">
<attribute name="Specification-Title"
value="Jakarta ORO" />
<attribute name="Specification-Version"
value="${version}" />
<attribute name="Specification-Vendor"
value="Apache Software Foundation" />
<attribute name="Implementation-Title"
value="org.apache.oro" />
<attribute name="Implementation-Version"
value="${version} ${DATE}" />
<attribute name="Implementation-Vendor"
value="Apache Software Foundation" />
</section>
</manifest>
</jar>
</target>
<!-- javadocs target. Creates the API documentation -->
<target name="javadocs" depends="prepare"
description="Creates the API documentation.">
<mkdir dir="${javadoc.destdir}"/>
<javadoc packagenames="org.apache.oro.io,org.apache.oro.text,org.apache.oro.text.regex,org.apache.oro.text.awk,org.apache.oro.text.perl,org.apache.oro.util"
sourcepath="${build.src}"
destdir="${javadoc.destdir}"
overview="${build.src}/org/apache/oro/overview.html"
author="true"
version="true"
windowtitle="${name} ${version} API"
doctitle="${name} ${version} API"
header="<a href='http://jakarta.apache.org/oro/' target=_top><img src='{@docroot}/../images/logoSmall.gif' alt='Jakarta ORO' width=48 height=47 align=center border=0 hspace=1 vspace=1></a>"
bottom="Copyright © ${year} Apache Software Foundation. All Rights Reserved.">
</javadoc>
<replace file="${javadoc.destdir}/overview-frame.html"
token="{@docroot}" value="."/>
<replace dir="${javadoc.destdir}" includes="**/*.html"
token="@version@" value="${version}"/>
</target>
<!-- docs target. Creates project web pages and documentation. -->
<target name="docs" depends="prepare-error,lib,examples"
description="Creates the project web pages and documentation."
if="AnakiaTask.present">
<taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
<classpath>
<fileset dir="${jakarta-site2.dir}/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<anakia basedir="${docs.src}" destdir="${docs.dest}/"
extension=".html" style="./site.vsl"
projectFile="stylesheets/project.xml"
excludes="**/stylesheets/** manual/** empty.xml"
includes="**/*.xml"
lastModifiedCheck="true"
templatePath="${jakarta-site2.dir}/xdocs/stylesheets">
</anakia>
< todir="${docs.dest}/images" filtering="no">
<fileset dir="${docs.src}/images">
<include name="**/*.gif"/>
<include name="**/*.jpeg"/>
<include name="**/*.jpg"/>
</fileset>
</>
<mkdir dir="${docs.dest}/classes"/>
<mkdir dir="${docs.dest}/classes/examples"/>
< todir="${docs.dest}/classes/examples" filtering="no">
<fileset dir="${build.dest}/examples">
<include name="MatcherDemoApplet.class"/>
</fileset>
</>
<mkdir dir="${docs.dest}/classes/org"/>
< todir="${docs.dest}/classes/org" filtering="no">
<fileset dir="${build.dest}/org">
<include name="**/*.class"/>
</fileset>
</>
</target>
<!-- package target -->
<target name="package" depends="jar,javadocs,docs"
description="Creates a distribution directory tree.">
<mkdir dir="${final.dir}"/>
< todir="${final.dir}/src">
<fileset dir="${code.src}"/>
</>
<!-- BEGIN_REMOVE_THIS -->
<!-- Remove this when there's a first draft of the manual. -->
< todir="${final.dir}/docs">
<fileset dir="${docs.dest}">
<exclude name="manual/**"/>
</fileset>
</>
<!-- END_REMOVE_THIS -->
< file="${top.dir}/build.xml" tofile="${final.dir}/build.xml"/>
< file="${top.dir}/build.properties"
tofile="${final.dir}/build.properties"/>
< file="${top.dir}/LICENSE" tofile="${final.dir}/LICENSE"/>
< file="${top.dir}/ISSUES" tofile="${final.dir}/ISSUES"/>
< file="${top.dir}/CHANGES" tofile="${final.dir}/CHANGES"/>
< file="${top.dir}/COMPILE" tofile="${final.dir}/COMPILE"/>
< file="${top.dir}/CONTRIBUTORS"
tofile="${final.dir}/CONTRIBUTORS"/>
< file="${top.dir}/README" tofile="${final.dir}/README"/>
< file="${top.dir}/STYLE" tofile="${final.dir}/STYLE"/>
< file="${top.dir}/TODO" tofile="${final.dir}/TODO"/>
< file="${top.dir}/${final.name}.jar" tofile="${final.dir}/${final.name}.jar"/>
</target>
<!-- package-zip target. Packages the distribution with ZIP -->
<target name="package-zip" depends="package"
description="Packages the distribution as a zip file.">
<zip zipfile="${top.dir}/${final.name}.zip" basedir="${top.dir}/"
includes="**/${final.name}/**" excludes="**/.cvsignore"/>
</target>
<!-- Packages the distribution with TAR-GZIP -->
<target name="package-tgz" depends="package"
description="Packages the distribution as a gzipped tar file.">
<tar tarfile="${top.dir}/${final.name}.tar"
basedir="${top.dir}" excludes="**/**">
<tarfileset dir="${final.dir}/..">
<include name="${final.name}/**"/>
<exclude name="**/.cvsignore"/>
</tarfileset>
</tar>
<gzip zipfile="${top.dir}/${project}-${version}.tar.gz" src="${top.dir}/${project}-${version}.tar"/>
</target>
<!-- Packages the distribution with ZIP and TAG-GZIP -->
<target name="package-all" depends="package-zip, package-tgz">
</target>
<!-- Makes an attempt to clean up a little. -->
<target name="clean"
description="Removes generated artifacts from source tree.">
<delete dir="${build.dest}"/>
<delete dir="${javadoc.destdir}"/>
<delete dir="${final.dir}"/>
<delete file="${top.dir}/${final.name}.jar"/>
<delete file="${top.dir}/${final.name}.tar"/>
<delete file="${top.dir}/${final.name}.tar.gz"/>
<delete file="${top.dir}/${final.name}.zip"/>
<delete>
<fileset dir="${top.dir}" includes="velocity.log*"/>
</delete>
</target>
</project>
build.xml文件的编写可参见ant发行版中的使用文档
你也可以自己编写脚本打包,使用jdk发行版中的jar命令,例如:
#jar cmf myManifestFile myFile.jar *.class
注意还需要自己编写MANIFEST.MF文件配置包属性。具体可以参见javadoc
当然还可以使用集成开发环境提供的打包工具,如JBuilder提供打包工具,但这样程序的移植性不强,建议不要使用,就使用ant比较好。