Ok, so I am experimenting using a java program to open up HTML documents. So, what I have is a website already made. I have the website in a separate folder called " website" that is next to the src file. I want to then take the src folder and the website folder and put them into the same .jar file so you can then send the .jar file to any computer and when you run it, it opens the website. I'm not sure if I worded that well, so just let me know if you need more specifications.
Here is the code that opens the HTML file.
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
public class BrowserTest {
public static void main(String[] args) {
String url = "framePage.html";
File htmlFile = new File(url);
try {
Desktop.getDesktop().browse(htmlFile.toURI());
} catch (IOException e) {
e.printStackTrace();
}
}
}
UPDATED CODE
import java.awt.Desktop;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
public class BrowserTest {
public static void main(String[] args) {
System.out.println(BrowserTest.class.getResource("/Website/framePage.html"));
URL url = BrowserTest.class.getResource("/Website/framePage.html");
try {
Desktop.getDesktop().browse(url.toURI());
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
}