Added files for compiling as jar.

Added a manifest and two bat files to compile and run the software in a single jar file.
Added checking when reading pokemon to read from jar if necessary.
This commit is contained in:
Kristian Knarvik 2017-11-28 13:58:53 +01:00
parent 8860f39f2c
commit cbeca8eb5f
4 changed files with 13 additions and 0 deletions

1
Compile.bat Normal file
View File

@ -0,0 +1 @@
jar cvfm Game.jar manifest.txt *.class Pokemon.txt

View File

@ -239,6 +239,14 @@ public class Game {
} catch (FileNotFoundException e) {
System.out.println("You seem to be missing one of the necessary files to run this program.");
}
/** If the file is compiled as jar, this will prevent an empty list. */
if (pokemon.size() < 1) {
try (Scanner file = new Scanner(Game.class.getResourceAsStream("/Pokemon.txt"))) {
while (file.hasNextLine()) {
pokemon.add(new Pokemon(file.nextLine()));
}
}
}
return pokemon;
}

1
Run.bat Normal file
View File

@ -0,0 +1 @@
java -jar Game.jar -Dfile.encoding=UTF-8

3
manifest.txt Normal file
View File

@ -0,0 +1,3 @@
Main-Class: Game
Name: pokemon-cmd/package/
Sealed: true