简体   繁体   English

通过考虑依赖关系在ECLIPSE中部署可运行的jar

[英]Deploying a runnable jar in ECLIPSE by considering dependencies

I have a problem with deploying a JAVA project into a runnable jar file. 将JAVA项目部署到可运行的jar文件时遇到问题。 My project consists of two classes, namely “JFrame” and “Sudoku”. 我的项目包含两个类,即“ JFrame”和“ Sudoku”。 The “JFrame” is a GUI which has a button invoking the main method of the class “Sudoku”. “ JFrame”是具有按钮的GUI,该按钮调用了“ Sudoku”类的主要方法。 Also, the project must link to an external library including “com.google.ortools.constraintsolver.jar” and “jniconstraintsolver.dll”. 此外,该项目必须链接到一个外部库,包括“ com.google.ortools.constraintsolver.jar”和“ jniconstraintsolver.dll”。 When I push the button of the GUI within ECLIPSE environment, it returns the solution in the GUI textbox and everything is nice and OK. 当我在ECLIPSE环境中按下GUI的按钮时,它将在GUI文本框中返回解决方案,一切正常。 However, when I am deploying it into a runnable jar and then clicking on the GUI and then pushing the button, nothing happens!! 但是,当我将其部署到可运行的jar中,然后单击GUI并按按钮时,什么也没发生! Thanks everyone for help, in advance. 预先感谢大家的帮助。 Consider that I am a beginner in JAVA. 考虑一下我是JAVA的初学者。

Make sure that you extract all your project dependencies when you build runnable jar. 在构建可运行的jar时,请确保提取所有项目依赖项。 If you do it in Eclipse, then r.click the project root->export->runnable jar (check the correct option for the dependencies extraction). 如果您在Eclipse中执行此操作,则r。单击项目的root-> export-> runnable jar(检查依赖项提取的正确选项)。

在此处输入图片说明

If you package the jar from command line, check the jar comand manual for including runtime dependencies. 如果从命令行打包jar,请查看jar comand手册以获取运行时相关性。

Good Luck! 祝好运!

The solution was a piece of cake for my case. 解决方案对我来说是小菜一碟。 I simply put .dll file next to .jar file and Bingo!! 我只是将.dll文件放在.jar文件和Bingo旁边! I found that it checks the working dir each time executing the .jar file. 我发现它每次执行.jar文件时都会检查工作目录。

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

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