想把java程序打包成exe文件,于是下载了exe4j,以前没用过。看了教程,现在遇到的第一个问题是exe4j要求首先打包jar文件,不知道具体操作是不是这样:项目上点右键---Export---java---JAR file---next---点Browse---选择一个保存路径和jar名?请大家指教。
另外教程上说,第一次安装exe4j会弹出一个面板,要求指定jdk目录下/bin/java.exe文件。可是我安装的时候可能没指定,现在也不往出弹这个面板了,在哪里可以设置?

解决方案 »

  1.   

    exe4j这个没用过,但是要指定jdk,你可以重装一下,也可以看看配置文件有哪个地方可以设置。打jar包,你可以用ant打,直接把一个项目打包。
      

  2.   

    刚下载了一个打包插件fatjar,不会用,不知道该打包哪些不打包哪些?
      

  3.   

    In this step of the exe4j wizard [p. 5] , you enter the information required to start your application.
    The following properties of the java invocation can be edited in the General section of this step:
    • Main class
    Enter the fully qualified main class of your application. Next to the text field is a [...] chooser button
    that brings up a dialog with a list of all public main classes [p. 17] in the class path. To use this
    facility, you have to set up your classpath first (see below).
    • VM parameters
    If there are any VM parameters you would like to specify for the invocation of your Java application,
    you can enter them here (e.g. -Dmyapp.myproperty=true or -Xmx256m).
    There are several runtime-variables you can use to specify runtime directories:
    • %EXE4J_EXEDIR%
    This is the directory where the executable is located.
    • %EXE4J_JVM_HOME%
    This is the directory of the JRE that your executable is running with.
    • %EXE4J_TEMPDIR%
    For the "JAR in EXE" mode [p. 6] , this variable will contain the location of the temporary directory
    for the JAR files. In "regular mode" [p. 6] this variable is not used.
    These variables can be especially useful for adding JAR files to the bootclasspath.
    In addition to these VM parameters, a parameter file in the same directory as the executable is
    read and its contents are added to the existing VM parameters. The name of this parameter file is
    the same as the exe file with the extension *.vmoptions. For example, if your exe file is named
    hello.exe, the name of the VM parameter file is hello.vmoptions. In this file, each line is
    interpreted as a single VM parameter. For example, the contents of the VM parameter file could
    be:
    -Xmx128m
    -Xms32m
    - 8 -
    In addition to the VM parameters you can also modify the classpath in the *.vmoptions files with
    the following options:
    • -classpath [classpath]
    Replace the classpath of the generated launcher.
    • -classpath/a [classpath]
    Append to the classpath of the generated launcher.
    • -classpath/p [classpath]
    Prepend to the classpath of the generated launcher.
    You can use environment variables in the VM parameters with the following syntax:
    ${VARIABLE_NAME} where you replace VARIABLE_NAME with the desired environment variable.
    • arguments
    If you need to specify arguments for your main class, you can enter them here. Arguments passed
    to the executable will be appended to these arguments.
    • Allow VM passthrough parameters
    If you would like to allow the user to specify VM parameters with the syntax -J[VM parameter]
    (e.g. -J-Xmx512m), select the Allow VM passthrough parameters checkbox.
    In the Class path section of this step you can configure the class path and the error handling for
    missing class path entries. The class path list shows all class path entries that have been added so
    far. The following types of class path entries [p. 17] are available:
    • Scan directory
    • Directory
    • Archive
    • Environment variable
    The symbol prepended to an entry indicates that an error with that entry will lead to a startup failure
    with an error message displayed to the user. The control buttons on the right allow you to modify the
    contents of the class path list:
    • Add class path entry (key INS)
    Invokes the class path entry dialog [p. 17] . Upon closing the class path entry dialog with the [OK]
    button, a new class path entry will be appended to the bottom of the class path list.
    • Remove class path entry (key DEL)
    Removes the currently selected class path entry without further confirmation.
    • Move class path entry up (key ALT-UP)
    Moves the selected class path entry up one position in the class path list.
    • Move class path entry down (key ALT-DOWN)
    Moves the selected class path entry down one position in the class path list.
    - 9 -
    To change the error handling mode of a class path entry [p. 17] , select the class path entry and press
    [Toggle 'fail on error'] right below the class path list or choose the corresponding menu item from
    the context menu.
      

  4.   

    JBuilder中制作.exe文件方法:   
      1、菜单中选择【Wizards】-【Native   Executable   Builder....】弹出对话框   
      2、在弹出的对话框中第一步(Step   1   of   7)的【Name】输入一个名称,并取消【Always   create   archive   when   building   the   project】点击【Next】   
      3、根据需要悬着需要的类,再选择【Include   class   dependencies】,点击【Next】   
      4、根据需要悬着需要的库文件,再选择下面的4个单选,反复所有的需要的库,点击【Next】   
      5、默认点击【Next】   
      6、在(Step   5   of   7)的时候选择一个主类运行点击【Next】   
      7、在(Step   6   of   7)的时候选择运行平台【Next】   
      8、默认点击【Finish】,这时候在工程的目录窗口出现了一个在(Step   1   of   7)输入的【Name】目录   
      9、右击这个目录,选择【Rebuild....】,Jbuilder就开始编译和创建执行文件或是Jar文件了   
      10、等完成之后,该目录下右几个文件,一般是有至少一个jar文件,或是一个exe文件   
      11、在Window打开工程所在的目录,就可以看到里面的有几个刚才编译的文件   
      12、执行jar就是用java   -jar   ***.jar、执行exe直接双击   
    试试 看行不、