tag:blogger.com,1999:blog-8712770457197348465.post590601014769261264..comments2024-03-28T02:47:19.159-07:00Comments on Javarevisited: How to Load Resources from Classpath in Java with Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8712770457197348465.post-43020873962670585192020-05-24T00:23:19.164-07:002020-05-24T00:23:19.164-07:00Yes, I don't see a reason why you cannot, are ...Yes, I don't see a reason why you cannot, are you getting any issue? are you trying to load the resources from classpath or remote directory?javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-9581146639676670112020-05-20T02:10:24.823-07:002020-05-20T02:10:24.823-07:00If classes A, B and C are loaded from the same cla...If classes A, B and C are loaded from the same class loader, and if the file you seek is stored alongside X interface.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-41758397688227552062017-08-22T10:36:38.358-07:002017-08-22T10:36:38.358-07:00Hi Javin, I find your blogs very descriptive and e...Hi Javin, I find your blogs very descriptive and easy to understands. However, I have a question related to this.<br />If two classes implement an interface, and my project wishes to load a property file to JVM can i load it using the interface reference?<br />Example:<br /><br />Class A implements X{} and also<br />Class B implements X{}<br /><br />I wish to load a resource that will be used by Anonymoushttps://www.blogger.com/profile/06057148469885205493noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-21840658273767814742014-10-29T06:36:15.913-07:002014-10-29T06:36:15.913-07:00In case, I need to modify the name or version in t...In case, I need to modify the name or version in the property file, how can it be done directly to the file in the classpath?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-9946703913798911982014-08-01T07:44:31.348-07:002014-08-01T07:44:31.348-07:00@Anonymous, good find, thanks for that. I have swa...@Anonymous, good find, thanks for that. I have swapped the comment now.javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-91289426785124013882014-08-01T07:44:07.824-07:002014-08-01T07:44:07.824-07:00Hello @Jitendra, thanks for being a regular reader...Hello @Jitendra, thanks for being a regular reader of my blog. First one is type, yes it should be ResourceLoader.class.getResourceAsStream() but second one is fine. When you give "app.properties" in Eclipse it will search from your project root directory. This should not be problem if app.properties is present in your project directory. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-46326544827056441942014-08-01T03:16:56.056-07:002014-08-01T03:16:56.056-07:00comments "// loading resource using getResour...comments "// loading resource using getResourceAsStream() method " and "// loading resource using getResource() method" should be swapped.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-83583137368702554152014-08-01T03:13:02.337-07:002014-08-01T03:13:02.337-07:00I am big fan of yours and your javarevisited. beca...I am big fan of yours and your javarevisited. because of your blogs me and many friends got confidence in interview and able to clear my technical round. I really appreciate your work and time on this blogs.<br /><br />By executing above program and maybe i found two errors<br /><br />1. InputStream in = Test.class.getResourceAsStream("app.properties");<br />Here what Test indicates? ItAnonymoushttps://www.blogger.com/profile/10412402160949350625noreply@blogger.com