简体   繁体   English

Java应用程序部署

[英]Java application deploy

I have a Swing desktop application and have created a jar file which depends on library (which is kept in ./lib/ ) and a .txt file in the same folder. 我有一个Swing桌面应用程序,并创建了一个jar文件,它依赖于库(保存在./lib/ )和同一文件夹中的.txt文件。 Now to execute the jar I have written a .bat file which checks if Java is installed or not. 现在要执行jar,我编写了一个.bat文件,用于检查是否安装了Java。 If installed then I run the jar file with command: 如果已安装,那么我使用命令运行jar文件:

javaw -jar TagEdit.jar

Now there are two problems I am facing with this: 现在我面临两个问题:

  1. I would rather prefer a single executable, if possible. 如果可能的话,我宁愿选择一个可执行文件。
  2. As using bat file, the console is visible in back (looks kind of weird). 使用bat文件时,控制台在后面可见(看起来很奇怪)。 Is it possible to turn it off? 有可能把它关掉吗?
  3. Java is everywhere, and there are lots of applications that are built in Java and packaged in a setup, or given as exe . Java无处不在,并且有许多应用程序使用Java构建并打包在一个设置中,或者作为exe I Googled a lot but could not find a way to create a setup for the software or an exe . 我用Google搜索了很多但无法找到为软件或exe创建设置的方法。 How are those software packaged? 这些软件是如何打包的?

Have tried jlaunch, but could not get that to work correctly. 尝试了jlaunch,但无法让它正常工作。

Himz, Eclipse can automatically build a so-called "fat-jar" for you. Himz,Eclipse可以为你自动构建一个所谓的“胖罐”。 It is a jar that contains all the dependencies you need. 它是一个包含您需要的所有依赖项的jar。

If you are a happy Maven user, then you have two brilliant alternatives - the shade plugin, and the assembly plugin. 如果你是一个快乐的Maven用户,那么你有两个很棒的选择 - 树荫插件和组装插件。 They both can produce a "fat-jar" for you. 他们都可以为你制作一个“胖罐”。 :) :)

There are various answers to this. 对此有各种答案。

  • javaws.exe will execute the jar without the console appearing behind javaws.exe将执行jar而不会出现控制台

But I feel this isn't really the best way. 但我觉得这不是最好的方式。

  • I think should investigate using Java Web Start , So you create a JNLP file and have it jar downloaded from the web, I think, you can also have a desktop icon. 我认为应该调查使用Java Web Start ,所以你创建了一个JNLP文件并让它从网上下载jar,我想,你也可以有一个桌面图标。

If you don't want that 如果你不想那样

  • I think you can get/buy binary wrappers for the jar. 我想你可以获得/购买jar的二进制包装器。

You could convert it to an executable. 您可以将其转换为可执行文件。 Try Googling java to exe . 尝试谷歌搜索java到exe

Once that is done, you could package it up as an installer using NSIS . 完成后,您可以使用NSIS将其打包为安装程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM