0

thanks for attention, I struggled with such issue: I packed a JAR file with external libraries in Intellij Idea but when I am trying to lounch it, I see error:

 The file "city-data.json" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
Exception in thread "Animation Thread" java.lang.NullPointerException
        at processing.core.PApplet.join(PApplet.java:8950)
        at de.fhpotsdam.unfolding.data.GeoJSONReader.loadData(Unknown Source)
        at Map.setup(Map.java:45)
        at processing.core.PApplet.handleDraw(PApplet.java:2361)
        at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
        at processing.core.PApplet.run(PApplet.java:2256)
        at java.lang.Thread.run(Unknown Source)

But I see this file in this Jar archive ! When i lounch project from Intellij or Eclipse all works good. Please, help, what problem it can be.

Also i will be very grateful if somebody tell, how I can to collect all project to Jar file from the command line. I tried to make it with the help of commands such as

 jar cvfe MyJarName.jar MyMainClass *.class

but it don't work too, command line answered with a lot of errors like this

  • @Jens I don't think that this is a duplicate of the Null pointer Exception Question, even if it's the same exception, I think this is a resources problem http://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar – Anas EL KORCHI Aug 03 '16 at 09:23
  • @elkorchianas Thank for your message, but in article, that you wrote here I did not found any answer about my situation. So if you are not busy or it is not difficult to you, please, could you to inspect my question again? Thank for attention and help! – Stanislav. Aug 03 '16 at 13:36
  • the problem is you are trying to locate and to get a resources file (city-data.json) from your Jar, this works good from eclipse because eclipse already configure your class path to point on your route file so you can reference your file with the path directly, but when you try to do the same think with inside a JAR file your need to use a class loader to load as stream your file like that : AnyClass.class.getClassLoader().getResourceAsStream("com/company/somePackage/MyFile.txt"); – Anas EL KORCHI Aug 03 '16 at 15:02

0 Answers0