2013-10-25 87 views
0
public static void moveSQLite(){ 
     File source = new File("C:\\Users\\User\\Desktop\\System.Data.SQLite"); // Specify initial path 
     File target = new File("C:\\Windows\\Microsoft.NET\\assembly\\GAC_64"); // Desired path 

     // If the source location exists, delete the any old source files 
     // and copy the entire directory of the source to the target location 
     if(source.exists()){ 
      System.out.println("Installing SQLite Database."); 
      try { 
       FileUtils.deleteDirectory(target); 
       System.out.println("Deleting previous versions of System.Data.SQLite"); 
       System.out.println("\"" + source + "\"" + " was successfully" 
         + " copied to " + "\"" + target + "\""); 
       FileUtils.copyDirectory(source, target); 
       System.out.println("SQLite database has been installed."); 
      }catch (IOException e) { 
       e.printStackTrace(); 
      } 
     // Otherwise prompt the user that the source directory does not exist 
     }else{ 
      System.out.println("SQLite not found - are you sure you have it in the right directory?"); 
     } 
    } 

上面是我的用于Revit插件的“安装程序”的其中一种方法。它不是一个安装程序,而是一个将特定文件夹和文件移动到主机计算机上的目标的脚本。将.java“安装程序”转换为.jar可执行文件

这是我第一次为Java做“软件开发”,所以大部分软件开发实践对我来说都是未知的 - 我的问题是:如何将它打包为.jar或.msi,最好是用简单的命令行界面,使得用户可以:

  1. 对于其中安装程序包是所安装的Revit其中

安装

  • 选择目标路径(即在桌面上)选择源路径过程应尽可能无缝乐。这个脚本基本上取代了拖放 - 我已经完成了。

  • 回答

    0

    在eclipse中右键单击你的项目。导出 - >运行jar并选择实现该逻辑的主类。这将导出可运行的jar文件。

    此外,Install4j是非常好的包装,安装选项,它也支持多种操作系统。我个人使用过install4j(对于Windows和Mac平台),它非常简单并且可配置。 请参考以下网址,

    http://www.ej-technologies.com/products/install4j/overview.html

    +0

    对于我们的用途,我们并不需要商业解决方案。这真的很简单,只需将几个文件夹拖到两个目录即可!我也有后端的东西完成 - 我只需要一种方法来打包,作为用户可以双击并自动运行脚本的东西。把我写的(在.java中)写成.msi或.jar是我所要求的。 – theGreenCabbage

    +0

    请参阅帖子的第一部分.. –

    +1

    哎呀..掠过它 - >对不起!我是否需要将诸如System.out.println()之类的东西改为Console.out ....(或者它在Java中与控制台等效的方法)? – theGreenCabbage

    0

    设置在你的清单中Main-Class:和罐子将使用java -jar myapp.jar语法

    Setting an Application's Entry Point更多的背景信息,并就如何做到这一点的说明变得可执行。

    假设Installer.class有一个main()方法,并且是您的应用程序入口点。你的清单可能是这个样子:

    清单-版本:1.0
    创建-者:1.6.0_45-B06(Sun微系统公司)
    主类:com.foo.Installer

    然后运行java -jar installer.jar将调用com.foo.Installer

    在一些操作系统中,在瓶子双击还将推出主类。

    编辑如果你想将你的.jar.exe,那什么,我上面列出的还远远不够。在这种情况下,正如其他答案中提到的那样,您需要使用类似launch4j或其中一种商业选择。

    相关问题