Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Try this for asking for your class

String s = getClass().getName(); int i = s.lastIndexOf("."); if(i > -1) s = s.substring(i + 1); s = s + ".class"; System.out.println("name " +s); Object testPath = this.getClass().getResource(s); System.out.println(testPath); 

this code snippet is from this.getClass().getResource("").getPath() returns an incorrect paththis.getClass().getResource("").getPath() returns an incorrect path

Try this for asking for your class

String s = getClass().getName(); int i = s.lastIndexOf("."); if(i > -1) s = s.substring(i + 1); s = s + ".class"; System.out.println("name " +s); Object testPath = this.getClass().getResource(s); System.out.println(testPath); 

this code snippet is from this.getClass().getResource("").getPath() returns an incorrect path

Try this for asking for your class

String s = getClass().getName(); int i = s.lastIndexOf("."); if(i > -1) s = s.substring(i + 1); s = s + ".class"; System.out.println("name " +s); Object testPath = this.getClass().getResource(s); System.out.println(testPath); 

this code snippet is from this.getClass().getResource("").getPath() returns an incorrect path

Source Link
RamonBoza
  • 9k
  • 6
  • 39
  • 49

Try this for asking for your class

String s = getClass().getName(); int i = s.lastIndexOf("."); if(i > -1) s = s.substring(i + 1); s = s + ".class"; System.out.println("name " +s); Object testPath = this.getClass().getResource(s); System.out.println(testPath); 

this code snippet is from this.getClass().getResource("").getPath() returns an incorrect path