Quantcast
Channel: this.getClass().getResource("").getPath() returns an incorrect path - Stack Overflow
Browsing all 9 articles
Browse latest View live

Answer by shane for this.getClass().getResource("").getPath() returns an...

Print out absolute path for a file in your classpath i.e. build/resources/main/someFileInClassPath.txt Disclaimer, this is similar to another solution on this page that used TT.class..., but this did...

View Article



Answer by Prabhaker for this.getClass().getResource("").getPath() returns an...

Try use this code public game() { String className = this.getClass().getSimpleName(); String testPath = this.getClass().getResource(className+".class"); System.out.println("Current Running Location is...

View Article

Answer by tgkprog for this.getClass().getResource("").getPath() returns an...

If you want to load a file in the same path as the code then I suggest you put it in the same root folder as the code and not the same path as the class. Reason : class can be inside a jar, data file...

View Article

Answer by CodeBlind for this.getClass().getResource("").getPath() returns an...

The call to getResource([String]) requires a path relative to the folder that contains the class it is being called from. So, if you have the following, anything you pass into...

View Article

Answer by Alpesh Gediya for this.getClass().getResource("").getPath() returns...

ClassLoader loader = Test.class.getClassLoader(); System.out.println(loader.getResource("Test.class")); also Test.class.getProtectionDomain().getCodeSource().getLocation().getPath());

View Article


Answer by NINCOMPOOP for this.getClass().getResource("").getPath() returns an...

You can use : URL classURL = getClass().getProtectionDomain().getCodeSource().getLocation();

View Article

Answer by Makky for this.getClass().getResource("").getPath() returns an...

Try this. import java.io.File; public class TT { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String path = TT.class.getResource("").getPath(); File...

View Article

this.getClass().getResource("").getPath() returns an incorrect path

I am currently making a small simple Java program for my Computer Science Final, which needs to get the path of the current running class. The class files are in the C:\2013\game\ folder. To get this...

View Article


Answer by HungNM2 for this.getClass().getResource("").getPath() returns an...

Because you used class.getResource(filePath).getpath() in a *.jar file. So the path includes "!". If you want to get content of file in *.jar file, use the following...

View Article

Browsing all 9 articles
Browse latest View live




Latest Images