如何在Eclipse的.jar可执行文件中包含资源文件夹? [英] How to include resource folder in executable .jar file in eclipse?

查看:144
本文介绍了如何在Eclipse的.jar可执行文件中包含资源文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个应用程序,以使用各种参数(例如高度,体积或基本面积)对各种类型的多边形进行排序. Filename的参数包含多边形,排序类型,排序方法的参数,将通过命令行传递.该文件位于项目中src文件夹之外的资源文件夹中.我已经实现了所有程序,当我通过Eclipse运行配置使用pass参数运行时,它运行良好.但是,当我尝试使用cmd相同的参数运行.jar文件时,它会给我FileNotFoundException.

I need to create an application for sorting various types of polygons using various parameters such as height, volume or base area. Arguments for Filename which has parameters for polygons, Sort type, Sort method will be pass through command line.That file is in my resource folder outside my src folder in a project. I have implemented all programs, It works fine when I run using pass arguments through eclipse run configuration. But when I try to run my .jar file using cmd same arguments it gives me FileNotFoundException.

我使用7zip打开了jar文件,发现它从未将我的资源文件夹提取到.jar文件中.我在线搜索并尝试将我的资源文件夹包括在内以构建Eclipse的路径.但是仍然不起作用.

I opened my jar file using 7zip and noticed it never extracted my resource folder in .jar file. I searched online and tried including my resource folder in to build path of eclipse. But still does't work.

推荐答案

请按照以下步骤操作:

1)单击项目->属性->构建路径->源->添加文件夹,然后选择资源文件夹.

1) click project -> properties -> Build Path -> Source -> Add Folder and select resources folder.

2)创建您的JAR!

2) create your JAR!

您可以使用7zip进行检查,以确保您的JAR包含文件夹.

you can make sure your JAR contains folder by inspecting it using 7zip.

也请保留此链接 查看全文

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