0
Caused by: java.io.FileNotFoundException: town.zip (The system cannot find the f
ile specified)

When I try to load my 3d scene on Windows 7 from a JAR that was built on Linux and vice versa Linux gets the same error as the JAR was packages on Windows. I use just the normal settings for creating a runnable jar in eclipse. What am I doing wrong? This seems to have little or nothing to do with my actual code and is just a packing question.

The code that is loading the file, which works on the same platform on which it is built, is:

assetManager.registerLocator("town.zip", ZipLocator.class);

and this works when the project is run from eclipse or on the same platform as which it is built.

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
  • 1
    is this file supposed to be inside your jar or alongside it? – radai Jul 23 '12 at 05:42
  • It's supposed to be inside the jar and when I run it on the build platform it is OK. It is only between platforms it won't work which is confusing. Opening the Jar file I cannot find the file town.zip and adding it into the jar won't help either. – Niklas Rosencrantz Jul 23 '12 at 05:46
  • 1
    If it's inside a jar you have to load it as a resource instead of a file. See [this](http://stackoverflow.com/questions/574809/java-load-a-resource-contained-in-a-jar) answer for some tips. – Thomas Jul 23 '12 at 05:49
  • 1
    Show code that loads the file. – Strelok Jul 23 '12 at 06:01
  • @Thomas But I'm loading it exactly the way from the example and it works when the JAR is run on the same platform as which it is built. There must be some config in eclipse how to package the thing. – Niklas Rosencrantz Jul 23 '12 at 07:09
  • @Strelok I put the load code in the question now. Thanks for the comment. – Niklas Rosencrantz Jul 23 '12 at 07:10

1 Answers1

2

You didn't specify what frameworks you're using, but a quick Google search pointed that you're using the jmonkeyengine, it looks like the ZipLocator actually loads the files using new File(...), so your town.zip should actually sit alongside your JAR file and not packaged inside it.

Strelok
  • 50,229
  • 9
  • 102
  • 115