URL of my java class
Question
I am trying to find my java class URL in order to use it in a SWT.Browser component. My goal is to display a page located in the same folder as my .java file.
If anyone knows how to do it or has a better solution to display a local page in a SWT.Browser I would be glad to know it to ;p
Thanks in advance.
Solution
You can get the page's URL directly by using Class.getResource().
OTHER TIPS
This sounds like you want to access some resource in the classpath. This works as follows:
this.getClass().getResource("/classpath/to/resource/file");
That returns an URL, that directs to your resource. To address resources in classpath the string must start with a /. If your java-class is in the package example.package and your file (for example expample.file) is in the same directory, then the path will be: /example/package/example.file