Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how would I load local files relative to the current java file in JWebbrowser? I know that I could load my page with
Java
navigate("path");
the problem is how to set relative path!

for example my java code is in :
D:\Eclipse_Project\MyProject\src\javaCode\browser.java
and the html file is in :
D:\Eclipse_Project\MyProject\src\pages\html.html

but I don't want to use as follow:
Java
webBrowser.navigate("file:///D:/Eclipse_Project/MyProject/src/pages/html.html");

also I try following code but it didn't load!
String webContent = new Scanner(new File("src\\pages\\html.html")).useDelimiter("\\Z").next();
webBrowser.setHTMLContent(webContent);


note: my html file also contains CSS an javaScript.
Posted
Comments
Coder93 6-Aug-14 5:04am    
I find yhe problem with js code, it should load some picture( src/images/pic.png ), but I don't know how to set its path in my html.html file so thak it could find it!

1 solution

- create /resources in top level project folder
- add to classpath
- make sure resources are checked in the export also
- have fun

You can add data at any place, but it's common sense to make up a folder "res" / "resource" / "resources" (might even be "web" in your case) in the top level.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900