How to make a java version installer for my software(java swing app)?
如何为我的软件制作java版本安装程序(java swing app)?
The installer will copy a jar(Launcher) file and a folder with sound and images file in the installer to the user's desktop and AppDate folder.
安装程序会将jar(Launcher)文件和包含声音和图像文件的文件夹复制到用户的桌面和AppDate文件夹中。
My problem is how to "know" the user's name so I can copy the file to the user's Desktop and AppData folder and how to copy the file..
我的问题是如何“知道”用户的名字,以便我可以将文件复制到用户的Desktop和AppData文件夹以及如何复制文件。
Can someone help me. Thank
有人能帮我吗。谢谢
==Sorry for My Bad English==
==抱歉我的英语不好==
2 个解决方案
#1
3
Java Web Start is your best option. It handles everything, and it supports custom installers for things like setting up application data.
Java Web Start是您的最佳选择。它处理所有事情,并支持自定义安装程序,例如设置应用程序数据。
If your data files never change, you probably should bundle them in your .jar file and access them using Class.getResource
, rather than copying them to a user's application data directory.
如果您的数据文件永远不会更改,您可能应该将它们捆绑在.jar文件中并使用Class.getResource访问它们,而不是将它们复制到用户的应用程序数据目录中。
Using Java Web Start usually doesn't require writing any code. You just create a short XML file, give it a .jnlp extension, and put it on a web server with your .jar file. It usually looks something like this:
使用Java Web Start通常不需要编写任何代码。您只需创建一个简短的XML文件,为其提供.jnlp扩展名,并将其放在带有.jar文件的Web服务器上。它通常看起来像这样:
<?xml version="1.0"?>
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0.10//EN" "http://java.sun.com/dtd/JNLP-6.0.10.dtd">
<jnlp version="1.6"
codebase="http://www.example.com/myapp/"
href="MyApp.jnlp">
<information>
<title>MyApp</title>
<homepage href="http://www.example.com/myapp/"/>
<description>My application</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+"/>
<jar href="MyApp.jar" main="true"/>
</resources>
<application-desc/>
</jnlp>
More details can be found here.
更多详细信息可以在这里找到。
#2
0
Try using System.getEnv("APPDATA"). This should return APPDATA folder, system independent.
尝试使用System.getEnv(“APPDATA”)。这应该返回APPDATA文件夹,与系统无关。
#1
3
Java Web Start is your best option. It handles everything, and it supports custom installers for things like setting up application data.
Java Web Start是您的最佳选择。它处理所有事情,并支持自定义安装程序,例如设置应用程序数据。
If your data files never change, you probably should bundle them in your .jar file and access them using Class.getResource
, rather than copying them to a user's application data directory.
如果您的数据文件永远不会更改,您可能应该将它们捆绑在.jar文件中并使用Class.getResource访问它们,而不是将它们复制到用户的应用程序数据目录中。
Using Java Web Start usually doesn't require writing any code. You just create a short XML file, give it a .jnlp extension, and put it on a web server with your .jar file. It usually looks something like this:
使用Java Web Start通常不需要编写任何代码。您只需创建一个简短的XML文件,为其提供.jnlp扩展名,并将其放在带有.jar文件的Web服务器上。它通常看起来像这样:
<?xml version="1.0"?>
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0.10//EN" "http://java.sun.com/dtd/JNLP-6.0.10.dtd">
<jnlp version="1.6"
codebase="http://www.example.com/myapp/"
href="MyApp.jnlp">
<information>
<title>MyApp</title>
<homepage href="http://www.example.com/myapp/"/>
<description>My application</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.7+"/>
<jar href="MyApp.jar" main="true"/>
</resources>
<application-desc/>
</jnlp>
More details can be found here.
更多详细信息可以在这里找到。
#2
0
Try using System.getEnv("APPDATA"). This should return APPDATA folder, system independent.
尝试使用System.getEnv(“APPDATA”)。这应该返回APPDATA文件夹,与系统无关。