简体   繁体   English

Java应用启动器

[英]Java application launcher

I have written a very simple Java application. 我已经编写了一个非常简单的Java应用程序。 Can anyone tell me how to create a launcher like icon to run that application both in Ubuntu and Windows ?? 谁能告诉我如何创建一个类似图标的启动器来在Ubuntu和Windows中运行该应用程序?

Thanks in advance..!! 提前致谢..!!

An executable JAR should work fine for a launcher on both Windows and Linux. 对于Windows和Linux上的启动器, 可执行JAR应该都能正常运行。 However, that won't get you a custom icon. 但是,这不会为您提供自定义图标。

On Windows, you can use JSmooth , which will create a .exe wrapper around your JAR file. 在Windows上,您可以使用JSmooth ,它将在JAR文件周围创建一个.exe包装器。 The JSmooth program will let you create an icon for the EXE as well (it also has options such as getting the user to download the necessary version of the JVM, or only permitting one instance of the program to run). JSmooth程序还将允许您为EXE创建一个图标(它还具有使用户下载必要版本的JVM或仅允许运行该程序的一个实例等选项)。

If your java application is to be distributed from a web server, you should have a look at Java Web Start which can do what you ask for based on a JNLP-file. 如果要从Web服务器分发Java应用程序,则应查看Java Web Start,它可以根据JNLP文件执行您所要求的操作。 Notably see 值得注意的是

http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/guide/javaws/developersguide/faq.html#104 http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/guide/javaws/developersguide/faq.html#104

Ubuntu and Windows will both have different ways to launch the application. Ubuntu和Windows都将以不同的方式启动应用程序。 I see two routes to follow here. 我在这里看到两条路线。 One is to use Java Web Start and use a web interface to start your application. 一种是使用Java Web Start并使用Web界面启动应用程序。 The other is to search for some sort of 3rd party installer that will create setup/installation programs for all the platforms you want to use. 另一种是搜索某种第三方安装程序,该安装程序将为您要使用的所有平台创建安装/安装程序。

I actually used a third party install program before, InstallAnywhere, but it was almost ten years ago. 实际上,我之前曾经使用第三方安装程序InstallAnywhere,但是它已经差不多十年了。 It offered the functionality you are looking for, though. 它提供了您正在寻找的功能。

There are different ways to do this, sometimes the simplest is the best approach. 有多种方法可以做到这一点,有时最简单的方法就是最好的方法。 One solution as suggested is a simple starting script. 建议的一种解决方案是简单的启动脚本。 Roll your application into a jar, then include a script that does nothing more than "java -jar myscript.jar" . 将您的应用程序滚动到一个jar中,然后包含一个脚本,该脚本只不过执行"java -jar myscript.jar" I do this all the time for internal customers that may be running various types of *nix and whatever version of windows (a few macs as well). 我一直为可能正在运行各种类型的* nix和任何版本的Windows(以及一些Mac)的内部客户执行此操作。 How sophisticated you need it to be depends on the audience served. 您所需的复杂程度取决于所服务的受众。

Create a bat/shell script which starts your application. 创建一个bat / shell脚本来启动您的应用程序。 And than create a shortcut/launcher for it. 然后为其创建快捷方式/启动器。

Shortcut file in windows has extension lnk . Windows中的快捷方式文件的扩展名为lnk

Update 更新资料

See example - SQuirreL launch file . 请参见示例-SQuirreL启动文件

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

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