Error message: The file “countries.geo.json” is missing or inaccessible
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
java processing
add a comment |
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
java processing
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 tocountries.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
add a comment |
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
java processing
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
java processing
java processing
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 tocountries.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
add a comment |
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 tocountries.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
add a comment |
2 Answers
2
active
oldest
votes
"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
add a comment |
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
"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
add a comment |
"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
add a comment |
"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
"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
answered Jan 5 at 1:15
George ProfenzaGeorge Profenza
36.5k11113182
36.5k11113182
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Jan 2 at 19:08
answered Jan 2 at 18:05
DarkRiftDarkRift
19410
19410
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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