如何分发我的Java程序,以便双击单个文件可以运行? [英] How to distribute my Java program so that it is runnable by double-clicking a single file?

查看:105
本文介绍了如何分发我的Java程序,以便双击单个文件可以运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java丰富的客户端桌面应用程序。我想在工作中的一些电脑上分发,但是我从来没有这样做过。人们在我的工作场所也不是电脑,因为这是一个学生工作,我不会在那里呆多久,如果我可以让我的程序容易运行,使其可以运行,当人们双倍点击它。



我也不想手动安装一个JRE让它运行。基本上,我想知道的是如何使我的java应用程序通过双击轻松地运行(即使只在Windows上,没关系)。我很确定我需要包装正确的JRE版本,但我不知道这样做的正确方法。



我读了在某些网站上,您不应该将JRE与程序一起打包,因为它使人们有多个不同的版本,其中一些版本过时,导致安全问题,但这不是一个问题,因为这些计算机正在进行运行我的应用程序没有连接到互联网,只用于运行这个程序。



有点相关的问题:由于我的应用程序目前是一个Eclipse项目,我得到我的资源,如图标,图像,SQLite数据库(用于读取和写入)等使用相对路径(例如: img / test.png )。



我将不得不更改任何这些路径,让他们在打包时保持工作?

解决方案

您要查找的是JAR文件。在日食中,制作一个Jar文件很容易。具体来说,您需要右键单击项目,转到导出,然后选择Runnable Jar。小心文件夹的路径。您可能需要在Jar文件旁边保留资源文件夹。您可能需要提供一些更详细的信息才能得到确切的答案。通常,资源文件夹位于与JAR文件相同的位置(与计算机相同的文件夹中)。


I have a Java rich client desktop app. that I want to distribute on some computers at work, but I've never done something like this before. People aren't too computer-savy at my workplace and since it is a student job, I won't be there for much longer and I'd like it if I could make my program easy to run by making it runnable when people double-click on it.

I also don't want to have to manually install a JRE to have it run. Basically, what I'd like to know is how to make my java application runnable easily by double-clicking (even if it's only on windows, it's okay). I'm pretty sure I'm going to need to package the correct JRE version alongside, but I don't know what's the correct way of doing this.

I read on some sites that you should not package a JRE along with your program because it makes people have multiple different versions, some of which are outdated, and it causes security issues, but this is not a problem in this case since the computers that are going to run my application are not connected to the internet and are only used to run this program anyway.

Somewhat related question: Since my application is currently an Eclipse project, I get my resources such as icons, images, SQLite database (for read and write), etc. using relative paths (e.g.: img/test.png).

Am I going to have to change any of those paths to have them keep working even while packaged?

解决方案

What you're looking for is a JAR file. In eclipse, it's quite easy to make a Jar file. Specifically, you'll want to right click on your project, go to Export, and then select "Runnable Jar." Be careful with paths to folders. You may need to keep a resources folder next to the Jar file. You may need to provide some more specifics to get an exact answer on that. Typically, a Resources folder is located in the same spot as the JAR file (in the same folder on your computer).

这篇关于如何分发我的Java程序,以便双击单个文件可以运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆