kappa wrote:
all resource files (images, sounds, data like txt files) should go inside jar files, then you must read the file from the jar.
So what you need to do is check if it txt file exists on the user computer, if so then load it, otherwise load it from the jar and save it on the computer.
i dont know why
but for some reason when i launch the game its launching it and then nothing happen, the window wont open, no error nothing...
i want to make my program launch throw JNLP,
the problem is that when i launch the program throw JNLP it doesn't open the window and my program.
my program need 2 files, 1 is resources.jar that hold all the imgs and the sounds of the program
and the secound file is the config.properties that hold all the saves the used did in the options.
i got 2 problems with the JNLP,
1. the JNLP load but doesn't open my program (mean there is a problem)
2. how i do that the JNLP doesn't re-download every time the config.properties, after i save and change it?
for the first problem:
the code that run and use the resources.jar is this:
Code:
public void init(String jarLocation) throws IOException, SlickException {
list = LoadingList.get();
java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(jarLocation);
zipFile.entries();
JarFile jarFile = new JarFile(jarLocation);
Enumeration<JarEntry> e = jarFile.entries();
while (e.hasMoreElements()) {
JarEntry je = e.nextElement();
String path = je.getName();
if (path.startsWith("resources") && path.length() > 10) {
String dataInfo = path.split("/")[1];
if (!path.endsWith("/")) {
String name = path.split("/")[2].split("[.]")[0];
if (dataInfo.equals("images")) {
list.add(new DeferredImage(name, path));
} else {
if (dataInfo.equals("cards")) {
list.add(new DeferredCards(name, path));
}
}
}
}
}
}
and the jarLocation is "libs/resources.jar"
and the code that get and use the config is this:
Code:
public static void init(String fileLocation) throws IOException {
Configuration.fileLocation = fileLocation;
InputStreamReader is = new InputStreamReader(new FileInputStream(fileLocation));
configurationFile = new Properties();
configurationFile.load(is);
is.close();
}
the fileLocation is "config/config.properties"
my JNLP code looks like this:
(the game.jar is the program that use resources.jar and the config)
Code:
<resources>
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+" max-heap-size="128m"/>
<jar href="*site*/game.jar" main="true" />
<jar href="*site*/libs/resources.jar"/>
<jar href="*site*/libs/slick.jar" main="false"/>
<jar href="*site*/libs/lwjgl.jar" main="false"/>
<jar href="*site*/libs/twl.jar" main="false"/>
<jar href="*site*/libs/kryo-1.01.jar" main="false"/>
<jar href="*site*/libs/kryonet-1.01.jar" main="false"/>
<jar href="*site*/libs/xpp3-1.1.4c.jar" main="false"/>
<jar href="*site*/libs/minlog-1.2.jar" main="false"/>
<jar href="*site*/libs/jogg-0.0.7.jar" main="false"/>
<jar href="*site*/libs/jorbis-0.0.15.jar" main="false"/>
</resources>
and the manifest.mf of the game.jar is this:
Code:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Class-Path: libs/lwjgl.jar libs/slick.jar libs/resources.jar libs/ibxm
.jar libs/jogg-0.0.7.jar libs/jorbis-0.0.15.jar libs/xpp3-1.1.4c.jar
libs/asm-3.2.jar libs/kryo-1.01.jar libs/kryonet-1.01.jar libs/minlog
-1.2.jar libs/twl.jar libs/reflectasm-0.8.jar
Created-By: 1.6.0_21-b07 (Sun Microsystems Inc.)
Main-Class: azora.Launch
what is wrong and how i can fix both of this problems?