Cannot get IDEA to see JAR file when running simple Java Application from IDE Follow
I have a simple Java application where I'm trying to read a file in a JAR file like this:
InputStream inputStream = classLoader.getResourceAsStream("resource.properties");
This "resource.properties" is in a JAR file.
Trying to run this program standalone in IDEA, even with the JAR file in the "src" folder does not work since the jar file is not specifically mentioned.
To run this code at the command line (not using IDEA IDE), I'd first set the CLASSPATH like this:
CLASSPATH=.:resources.jar
export classpath
Then, it works (at the command line, without IDEA IDE)
---
OK, so my IDEA question is how do I make IDEA aware of this JAR file so the code will run within the IDE?
I've tried putting the JAR file in the dependencies tab as a JAR and also tried to "export" it. But running this program in IDEA always gives the NullPointerException since it can't find the JAR.
Then I also put the jar file as a library entry in IDEA.
NullPointerExceptions each time.
What's the trick to specify a JAR file (call it "resources.jar") in IDEA (13.0.1) so it will be recognized by IDEA?
Thanks,
m
Please sign in to leave a comment.
Hello.
> I've tried putting the JAR file in the dependencies tab as a JAR and also tried to "export" it. But running this program in IDEA always gives the NullPointerException since it can't find the JAR.
When you put the JAR to dependencies, and run the application, please check the command line shown in Run tool window. Is the required jar listed in -classpath argument?
Regards,
Alexander.
THANKS!
All fixed.