Error message: The file “countries.geo.json” is missing or inaccessible












-1















I am taking the Coursera OOP in Java class. In the module 4 assignment, I run the code that the course provides in EarthquakeCityMap.java,
and I get an error as "The file "countries.geo.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"



I tried to set countryFile as
"../data/countries.geo.json",
"data/countries.geo.json",
and the complete path of countries file,
but still didn't solve the problem.



//this error points to the code
private String countryFile = "countries.geo.json";
List<Feature> countries = GeoJSONReader.loadData(this, countryFile);"

//the countries file is saved in data folder.


Poject folder listing



Poject folder listing










share|improve this question




















  • 2





    I would trust the error and figure out where that file is.

    – Elliott Frisch
    Jan 2 at 2:37






  • 1





    What is the current directory when you run the code? The path to countries.geo.json must be relative to whatever that directory is.

    – Andreas
    Jan 2 at 2:48








  • 2





    Can you please post a Minimal, Complete, and Verifiable example?

    – Kevin Workman
    Jan 2 at 2:49











  • Please don't add irrelevant tags.

    – Robert
    Jan 2 at 19:13
















-1















I am taking the Coursera OOP in Java class. In the module 4 assignment, I run the code that the course provides in EarthquakeCityMap.java,
and I get an error as "The file "countries.geo.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"



I tried to set countryFile as
"../data/countries.geo.json",
"data/countries.geo.json",
and the complete path of countries file,
but still didn't solve the problem.



//this error points to the code
private String countryFile = "countries.geo.json";
List<Feature> countries = GeoJSONReader.loadData(this, countryFile);"

//the countries file is saved in data folder.


Poject folder listing



Poject folder listing










share|improve this question




















  • 2





    I would trust the error and figure out where that file is.

    – Elliott Frisch
    Jan 2 at 2:37






  • 1





    What is the current directory when you run the code? The path to countries.geo.json must be relative to whatever that directory is.

    – Andreas
    Jan 2 at 2:48








  • 2





    Can you please post a Minimal, Complete, and Verifiable example?

    – Kevin Workman
    Jan 2 at 2:49











  • Please don't add irrelevant tags.

    – Robert
    Jan 2 at 19:13














-1












-1








-1








I am taking the Coursera OOP in Java class. In the module 4 assignment, I run the code that the course provides in EarthquakeCityMap.java,
and I get an error as "The file "countries.geo.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"



I tried to set countryFile as
"../data/countries.geo.json",
"data/countries.geo.json",
and the complete path of countries file,
but still didn't solve the problem.



//this error points to the code
private String countryFile = "countries.geo.json";
List<Feature> countries = GeoJSONReader.loadData(this, countryFile);"

//the countries file is saved in data folder.


Poject folder listing



Poject folder listing










share|improve this question
















I am taking the Coursera OOP in Java class. In the module 4 assignment, I run the code that the course provides in EarthquakeCityMap.java,
and I get an error as "The file "countries.geo.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"



I tried to set countryFile as
"../data/countries.geo.json",
"data/countries.geo.json",
and the complete path of countries file,
but still didn't solve the problem.



//this error points to the code
private String countryFile = "countries.geo.json";
List<Feature> countries = GeoJSONReader.loadData(this, countryFile);"

//the countries file is saved in data folder.


Poject folder listing



Poject folder listing







java processing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 4 at 20:40







ki45123ki

















asked Jan 2 at 2:34









ki45123kiki45123ki

33




33








  • 2





    I would trust the error and figure out where that file is.

    – Elliott Frisch
    Jan 2 at 2:37






  • 1





    What is the current directory when you run the code? The path to countries.geo.json must be relative to whatever that directory is.

    – Andreas
    Jan 2 at 2:48








  • 2





    Can you please post a Minimal, Complete, and Verifiable example?

    – Kevin Workman
    Jan 2 at 2:49











  • Please don't add irrelevant tags.

    – Robert
    Jan 2 at 19:13














  • 2





    I would trust the error and figure out where that file is.

    – Elliott Frisch
    Jan 2 at 2:37






  • 1





    What is the current directory when you run the code? The path to countries.geo.json must be relative to whatever that directory is.

    – Andreas
    Jan 2 at 2:48








  • 2





    Can you please post a Minimal, Complete, and Verifiable example?

    – Kevin Workman
    Jan 2 at 2:49











  • Please don't add irrelevant tags.

    – Robert
    Jan 2 at 19:13








2




2





I would trust the error and figure out where that file is.

– Elliott Frisch
Jan 2 at 2:37





I would trust the error and figure out where that file is.

– Elliott Frisch
Jan 2 at 2:37




1




1





What is the current directory when you run the code? The path to countries.geo.json must be relative to whatever that directory is.

– Andreas
Jan 2 at 2:48







What is the current directory when you run the code? The path to countries.geo.json must be relative to whatever that directory is.

– Andreas
Jan 2 at 2:48






2




2





Can you please post a Minimal, Complete, and Verifiable example?

– Kevin Workman
Jan 2 at 2:49





Can you please post a Minimal, Complete, and Verifiable example?

– Kevin Workman
Jan 2 at 2:49













Please don't add irrelevant tags.

– Robert
Jan 2 at 19:13





Please don't add irrelevant tags.

– Robert
Jan 2 at 19:13












2 Answers
2






active

oldest

votes


















0














"countries.geo.json" (unless changed in GeoJSONReader manipulates this path) will be relative to the compiled java .class files in the IntelliJ's project out folder.



If this in GeoJSONReader.loadData(this, countryFile); is a PApplet instance you can use sketchPath() to make that path relative to the folder from which the sketch runs:



List<Feature> countries = GeoJSONReader.loadData(this, this.sketchPath("data"+File.separator+countryFile));


The above snippet is based on an assumption so the syntax in your code might be slightly different, but hopefully this illustrates how you'd use sketchPath().



Additionally there's a dataPath() as well which you can test from your main PApplet in setup() as a test:



String fullJSONPath = dataPath("countries.geo.json");
println("fullJSONPath: " + fullJSONPath);//hopefully this prints the full path to the json file on your machine
println(new File(fullJSONPath).exists());//hopefully this prints true





share|improve this answer































    0














    If you specified the full path and it didn’t work, you probably forgot to escape the character with another backslash. The backslash character is special and needs to be doubled for windows path to be interpreted properly. For instance “c:\users\...”. You can also specify / instead of and it would work : “c:/users/...”



    That said, the path resolution of a file when relative (IE not being absolute to the file system root) is relative to the working directory of the executed app. Typically, in an IDE without any special configuration, the working directory would be the root path of the project. So in order to get the relative file path resolved properly, you would have to specify the path as “data/countries.geo.json”.



    You can also find out what path you are in when you run the app by doing a System.out.println(new java.io.File(“.”).getAbsolutePath()) and craft the relative path according to this folder.






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000598%2ferror-message-the-file-countries-geo-json-is-missing-or-inaccessible%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      "countries.geo.json" (unless changed in GeoJSONReader manipulates this path) will be relative to the compiled java .class files in the IntelliJ's project out folder.



      If this in GeoJSONReader.loadData(this, countryFile); is a PApplet instance you can use sketchPath() to make that path relative to the folder from which the sketch runs:



      List<Feature> countries = GeoJSONReader.loadData(this, this.sketchPath("data"+File.separator+countryFile));


      The above snippet is based on an assumption so the syntax in your code might be slightly different, but hopefully this illustrates how you'd use sketchPath().



      Additionally there's a dataPath() as well which you can test from your main PApplet in setup() as a test:



      String fullJSONPath = dataPath("countries.geo.json");
      println("fullJSONPath: " + fullJSONPath);//hopefully this prints the full path to the json file on your machine
      println(new File(fullJSONPath).exists());//hopefully this prints true





      share|improve this answer




























        0














        "countries.geo.json" (unless changed in GeoJSONReader manipulates this path) will be relative to the compiled java .class files in the IntelliJ's project out folder.



        If this in GeoJSONReader.loadData(this, countryFile); is a PApplet instance you can use sketchPath() to make that path relative to the folder from which the sketch runs:



        List<Feature> countries = GeoJSONReader.loadData(this, this.sketchPath("data"+File.separator+countryFile));


        The above snippet is based on an assumption so the syntax in your code might be slightly different, but hopefully this illustrates how you'd use sketchPath().



        Additionally there's a dataPath() as well which you can test from your main PApplet in setup() as a test:



        String fullJSONPath = dataPath("countries.geo.json");
        println("fullJSONPath: " + fullJSONPath);//hopefully this prints the full path to the json file on your machine
        println(new File(fullJSONPath).exists());//hopefully this prints true





        share|improve this answer


























          0












          0








          0







          "countries.geo.json" (unless changed in GeoJSONReader manipulates this path) will be relative to the compiled java .class files in the IntelliJ's project out folder.



          If this in GeoJSONReader.loadData(this, countryFile); is a PApplet instance you can use sketchPath() to make that path relative to the folder from which the sketch runs:



          List<Feature> countries = GeoJSONReader.loadData(this, this.sketchPath("data"+File.separator+countryFile));


          The above snippet is based on an assumption so the syntax in your code might be slightly different, but hopefully this illustrates how you'd use sketchPath().



          Additionally there's a dataPath() as well which you can test from your main PApplet in setup() as a test:



          String fullJSONPath = dataPath("countries.geo.json");
          println("fullJSONPath: " + fullJSONPath);//hopefully this prints the full path to the json file on your machine
          println(new File(fullJSONPath).exists());//hopefully this prints true





          share|improve this answer













          "countries.geo.json" (unless changed in GeoJSONReader manipulates this path) will be relative to the compiled java .class files in the IntelliJ's project out folder.



          If this in GeoJSONReader.loadData(this, countryFile); is a PApplet instance you can use sketchPath() to make that path relative to the folder from which the sketch runs:



          List<Feature> countries = GeoJSONReader.loadData(this, this.sketchPath("data"+File.separator+countryFile));


          The above snippet is based on an assumption so the syntax in your code might be slightly different, but hopefully this illustrates how you'd use sketchPath().



          Additionally there's a dataPath() as well which you can test from your main PApplet in setup() as a test:



          String fullJSONPath = dataPath("countries.geo.json");
          println("fullJSONPath: " + fullJSONPath);//hopefully this prints the full path to the json file on your machine
          println(new File(fullJSONPath).exists());//hopefully this prints true






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 5 at 1:15









          George ProfenzaGeorge Profenza

          36.5k11113182




          36.5k11113182

























              0














              If you specified the full path and it didn’t work, you probably forgot to escape the character with another backslash. The backslash character is special and needs to be doubled for windows path to be interpreted properly. For instance “c:\users\...”. You can also specify / instead of and it would work : “c:/users/...”



              That said, the path resolution of a file when relative (IE not being absolute to the file system root) is relative to the working directory of the executed app. Typically, in an IDE without any special configuration, the working directory would be the root path of the project. So in order to get the relative file path resolved properly, you would have to specify the path as “data/countries.geo.json”.



              You can also find out what path you are in when you run the app by doing a System.out.println(new java.io.File(“.”).getAbsolutePath()) and craft the relative path according to this folder.






              share|improve this answer






























                0














                If you specified the full path and it didn’t work, you probably forgot to escape the character with another backslash. The backslash character is special and needs to be doubled for windows path to be interpreted properly. For instance “c:\users\...”. You can also specify / instead of and it would work : “c:/users/...”



                That said, the path resolution of a file when relative (IE not being absolute to the file system root) is relative to the working directory of the executed app. Typically, in an IDE without any special configuration, the working directory would be the root path of the project. So in order to get the relative file path resolved properly, you would have to specify the path as “data/countries.geo.json”.



                You can also find out what path you are in when you run the app by doing a System.out.println(new java.io.File(“.”).getAbsolutePath()) and craft the relative path according to this folder.






                share|improve this answer




























                  0












                  0








                  0







                  If you specified the full path and it didn’t work, you probably forgot to escape the character with another backslash. The backslash character is special and needs to be doubled for windows path to be interpreted properly. For instance “c:\users\...”. You can also specify / instead of and it would work : “c:/users/...”



                  That said, the path resolution of a file when relative (IE not being absolute to the file system root) is relative to the working directory of the executed app. Typically, in an IDE without any special configuration, the working directory would be the root path of the project. So in order to get the relative file path resolved properly, you would have to specify the path as “data/countries.geo.json”.



                  You can also find out what path you are in when you run the app by doing a System.out.println(new java.io.File(“.”).getAbsolutePath()) and craft the relative path according to this folder.






                  share|improve this answer















                  If you specified the full path and it didn’t work, you probably forgot to escape the character with another backslash. The backslash character is special and needs to be doubled for windows path to be interpreted properly. For instance “c:\users\...”. You can also specify / instead of and it would work : “c:/users/...”



                  That said, the path resolution of a file when relative (IE not being absolute to the file system root) is relative to the working directory of the executed app. Typically, in an IDE without any special configuration, the working directory would be the root path of the project. So in order to get the relative file path resolved properly, you would have to specify the path as “data/countries.geo.json”.



                  You can also find out what path you are in when you run the app by doing a System.out.println(new java.io.File(“.”).getAbsolutePath()) and craft the relative path according to this folder.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 2 at 19:08

























                  answered Jan 2 at 18:05









                  DarkRiftDarkRift

                  19410




                  19410






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000598%2ferror-message-the-file-countries-geo-json-is-missing-or-inaccessible%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      'app-layout' is not a known element: how to share Component with different Modules

                      android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                      WPF add header to Image with URL pettitions [duplicate]