How can I open (java.awt.Desktop) these files in the resource folder of my project or use the as a inputStream?How to package resources in Jar properlyHow do I read / convert an InputStream into a String in Java?How to get the path of a running JAR file?How can I create an executable JAR with dependencies using Maven?How do I convert a String to an InputStream in Java?How can I convert a stack trace to a string?How to create a project from existing source in Eclipse and then find it?How to avoid Java code in JSP files?How to add local jar files to a Maven project?How do I load a file from resource folder?How to get absolute path to file in /resources folder in your project
Bypass with wrong cvv of debit card and getting OTP
PhD: When to quit and move on?
Park the computer
How do I iterate equal values with the standard library?
What do I need to see before Spider-Man: Far From Home?
How to deal with a Murder Hobo Paladin?
What is exact meaning of “ich wäre gern”?
What do you call the angle of the direction of an airplane?
n-level Ouroboros Quine
Can a Time Lord survive with just one heart?
Do intermediate subdomains need to exist?
Change the default text editor in Terminal
Motorcyle Chain needs to be cleaned every time you lube it?
Why does mean tend be more stable in different samples than median?
Dualizable object in the category of locally presentable categories
Do I need to be legally qualified to install a Hive smart thermostat?
Is conquering your neighbors to fight a greater enemy a valid strategy?
What causes a fastener to lock?
When is one 'Ready' to make Original Contributions to Mathematics?
Can you take the Dodge action while prone?
In the Seventh Seal why does Death let the chess game happen?
Curve fitting when data has a sharp initial slope and then tapers off
Why no parachutes in the Orion AA2 abort test?
Does the Milky Way orbit around anything?
How can I open (java.awt.Desktop) these files in the resource folder of my project or use the as a inputStream?
How to package resources in Jar properlyHow do I read / convert an InputStream into a String in Java?How to get the path of a running JAR file?How can I create an executable JAR with dependencies using Maven?How do I convert a String to an InputStream in Java?How can I convert a stack trace to a string?How to create a project from existing source in Eclipse and then find it?How to avoid Java code in JSP files?How to add local jar files to a Maven project?How do I load a file from resource folder?How to get absolute path to file in /resources folder in your project
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I can't use these files in my resource folder, what is wrong with my code?
The files are in a resources folder which is a subfolder of "src"
I tried absolute and a relative path. Nothing works anymore.
Desktop.getDesktop().open(new File("resources/testfile.png"));
This is how my files are stored in my project
java
add a comment |
I can't use these files in my resource folder, what is wrong with my code?
The files are in a resources folder which is a subfolder of "src"
I tried absolute and a relative path. Nothing works anymore.
Desktop.getDesktop().open(new File("resources/testfile.png"));
This is how my files are stored in my project
java
Just to clarify, you do not expect the resources folder to somehow be packaged into the jar that gets built when compiling your project? There are posts on that, like this one, stackoverflow.com/questions/7263505/…. I'm shocked loading that png via correct absolute path does not work. You show a relative path in your example. If that's the case, it looks like you need to be running your program from the src directory based on that screenshot. Is that what you're doing? If so, I suspect you have a file permissions issue.
– Evan
Mar 25 at 20:01
Is this problem in IDE or only when you packaged it as a jar file?
– Willey3x37
Jun 30 at 19:03
add a comment |
I can't use these files in my resource folder, what is wrong with my code?
The files are in a resources folder which is a subfolder of "src"
I tried absolute and a relative path. Nothing works anymore.
Desktop.getDesktop().open(new File("resources/testfile.png"));
This is how my files are stored in my project
java
I can't use these files in my resource folder, what is wrong with my code?
The files are in a resources folder which is a subfolder of "src"
I tried absolute and a relative path. Nothing works anymore.
Desktop.getDesktop().open(new File("resources/testfile.png"));
This is how my files are stored in my project
java
java
edited Mar 25 at 19:53
Willey3x37
asked Mar 25 at 19:33
Willey3x37Willey3x37
376 bronze badges
376 bronze badges
Just to clarify, you do not expect the resources folder to somehow be packaged into the jar that gets built when compiling your project? There are posts on that, like this one, stackoverflow.com/questions/7263505/…. I'm shocked loading that png via correct absolute path does not work. You show a relative path in your example. If that's the case, it looks like you need to be running your program from the src directory based on that screenshot. Is that what you're doing? If so, I suspect you have a file permissions issue.
– Evan
Mar 25 at 20:01
Is this problem in IDE or only when you packaged it as a jar file?
– Willey3x37
Jun 30 at 19:03
add a comment |
Just to clarify, you do not expect the resources folder to somehow be packaged into the jar that gets built when compiling your project? There are posts on that, like this one, stackoverflow.com/questions/7263505/…. I'm shocked loading that png via correct absolute path does not work. You show a relative path in your example. If that's the case, it looks like you need to be running your program from the src directory based on that screenshot. Is that what you're doing? If so, I suspect you have a file permissions issue.
– Evan
Mar 25 at 20:01
Is this problem in IDE or only when you packaged it as a jar file?
– Willey3x37
Jun 30 at 19:03
Just to clarify, you do not expect the resources folder to somehow be packaged into the jar that gets built when compiling your project? There are posts on that, like this one, stackoverflow.com/questions/7263505/…. I'm shocked loading that png via correct absolute path does not work. You show a relative path in your example. If that's the case, it looks like you need to be running your program from the src directory based on that screenshot. Is that what you're doing? If so, I suspect you have a file permissions issue.
– Evan
Mar 25 at 20:01
Just to clarify, you do not expect the resources folder to somehow be packaged into the jar that gets built when compiling your project? There are posts on that, like this one, stackoverflow.com/questions/7263505/…. I'm shocked loading that png via correct absolute path does not work. You show a relative path in your example. If that's the case, it looks like you need to be running your program from the src directory based on that screenshot. Is that what you're doing? If so, I suspect you have a file permissions issue.
– Evan
Mar 25 at 20:01
Is this problem in IDE or only when you packaged it as a jar file?
– Willey3x37
Jun 30 at 19:03
Is this problem in IDE or only when you packaged it as a jar file?
– Willey3x37
Jun 30 at 19:03
add a comment |
0
active
oldest
votes
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%2f55345195%2fhow-can-i-open-java-awt-desktop-these-files-in-the-resource-folder-of-my-proje%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
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%2f55345195%2fhow-can-i-open-java-awt-desktop-these-files-in-the-resource-folder-of-my-proje%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
Just to clarify, you do not expect the resources folder to somehow be packaged into the jar that gets built when compiling your project? There are posts on that, like this one, stackoverflow.com/questions/7263505/…. I'm shocked loading that png via correct absolute path does not work. You show a relative path in your example. If that's the case, it looks like you need to be running your program from the src directory based on that screenshot. Is that what you're doing? If so, I suspect you have a file permissions issue.
– Evan
Mar 25 at 20:01
Is this problem in IDE or only when you packaged it as a jar file?
– Willey3x37
Jun 30 at 19:03