Creating Runnable Jar with external files included

后端 未结 2 1646
日久生厌
日久生厌 2020-11-28 14:28

I want to build a runnable jar in java. I need to include some of the files in the jar so that when I execute jar the files are automatically read from the java class. Henc

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 15:04

    Problem Solved!

    here is how:

    1) right click your project folder and create a new folder.

    2) move all of your files that you want packed into the jar into that folder.

    3) click project -> properties -> Build Path -> Source -> Add Folder and select that folder you just created.

    4) create your JAR!

    Since you already have created your folder with abc.txt insideit, you can skip steps 1 and 2

    EDIT: one way you can make sure your JAR contains these files is to use 7zip.

提交回复
热议问题