I'm trying to develop a desktop application that should load images from local file system.
Here after is a sample application that uses various way to do that (loading from jar, file and resources).
In netbeans
A) Right click on the project -> "run" -> only the image 1 and 2 are loaded
B) Right click on the main project file -> "run file" -> there all loaded except 4
I'm really wondering what's happening here ?
------------------------------------------------------------
TestWebEngine.java (in a package test)
------------------------------------------------------------
package test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class TestWebEngine extends Application {
@Override public void start(Stage stage) {
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
webEngine.load(getClass().getResource("/index.html").toExternalForm());
stage.setScene(new Scene(webView, 1280, 900));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
------------------------------------------------------------
index.html (in the root project folder)
------------------------------------------------------------
<!doctype html>
<html lang="en">
<head>
<title>LOAD LOCAL IMAGES</title>
</head>
<body>
<img src="test.png" alt="test1"/>
<img src="jar:file:///Users/Badisi/test.jar!/test.png" alt="test2"/>
<img src="file:/Users/Badisi/test.png" alt="test3"/>
<img src="file://Users/Badisi/test.png" alt="test4"/>
<img src="file:///Users/Badisi/test.png" alt="test5"/>
</body>
</html>
------------------------------------------------------------
test.png (in the root project folder)
------------------------------------------------------------
Here after is a sample application that uses various way to do that (loading from jar, file and resources).
In netbeans
A) Right click on the project -> "run" -> only the image 1 and 2 are loaded
B) Right click on the main project file -> "run file" -> there all loaded except 4
I'm really wondering what's happening here ?
------------------------------------------------------------
TestWebEngine.java (in a package test)
------------------------------------------------------------
package test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class TestWebEngine extends Application {
@Override public void start(Stage stage) {
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
webEngine.load(getClass().getResource("/index.html").toExternalForm());
stage.setScene(new Scene(webView, 1280, 900));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
------------------------------------------------------------
index.html (in the root project folder)
------------------------------------------------------------
<!doctype html>
<html lang="en">
<head>
<title>LOAD LOCAL IMAGES</title>
</head>
<body>
<img src="test.png" alt="test1"/>
<img src="jar:file:///Users/Badisi/test.jar!/test.png" alt="test2"/>
<img src="file:/Users/Badisi/test.png" alt="test3"/>
<img src="file://Users/Badisi/test.png" alt="test4"/>
<img src="file:///Users/Badisi/test.png" alt="test5"/>
</body>
</html>
------------------------------------------------------------
test.png (in the root project folder)
------------------------------------------------------------