简体   繁体   English

在Eclipse中创建可运行的jar文件

[英]Create runnable jar file in Eclipse

  • I use sqljdbc driver for my project 我为我的项目使用sqljdbc驱动程序
  • I have a "libs" folder to store all libraries 我有一个“ libs”文件夹来存储所有库
  • To be able to connect to MSSQLServer I set "Native Library Location" for my sqljdbc4.jar. 为了能够连接到MSSQLServer,我为sqljdbc4.jar设置了“本地库位置”。 You see this native library location is in "libs" folder too 您会看到该本地库的位置也位于“ libs”文件夹中

在此处输入图片说明

  • Everything's OK,but when I create runnable jar file, I have connection problem 一切正常,但是当我创建可运行的jar文件时,出现连接问题

      org.hibernate.exception.JDBCConnectionException: Could not open connection 
  • It is caused by "no sqljdbc_auth in java.library.path" 这是由于“ java.library.path中没有sqljdbc_auth”引起的

What should I do to create a right runnable jar file? 我应该怎么做才能创建一个可运行的jar文件? Thanks in advance! 提前致谢!

You might need to add your sqljdbc driver to your Classpath Variables as follows: 您可能需要将sqljdbc驱动程序添加到Classpath Variables ,如下所示:

Window -> Preferences -> Java -> Build Path -> Classpath Variables

With the 'New' button you can add the name and the path to your file. 使用“新建”按钮,您可以为文件添加名称和路径。

Hope this helps ! 希望这可以帮助 !

OK I found it. 好,我找到了。 Add sqljdbc_auth.dll of driver to System32, and no need to add native library location anymore 将驱动程序的sqljdbc_auth.dll添加到System32,并且不再需要添加本机库位置

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

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