I'm trying to save an image to my file system as noted on the javafx image ops page: http://docs.oracle.com/javafx/2/image_ops/jfxpub-image_ops.htm but I keep getting this exception error:
java[80783:707] [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode.
This stackoverflow question sort of helped JavaFX screencapture headless exception on OSX but I am still stuck on saving an image.
Any way I can go about saving an image?
This is how I am currently doing it:
File outFileImage = new File(imageUrl);
Toolkit tk = java.awt.Toolkit.getDefaultToolkit().getDefaultToolkit();
try {
ImageIO.write(SwingFXUtils.fromFXImage(image, null), ".png", outFileImage);
} catch (Exception e) {
log.log(Level.WARNING, "Image not saved to disk", e);
}
EDIT
I attempted running Java 8 to see if the problem would be resolved but I kept getting JavaFX FXML errors:
javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load.
/Users/jonathan/Projects/Dominion/target/classes/dominion/application/controller/main_overview_tab.fxml:13
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2613)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:104)
at javafx.fxml.FXMLLoader$RootElement.constructValue(FXMLLoader.java:1320)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2723)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at dominion.application.controller.MainOverviewTab.initView(MainOverviewTab.java:64)
EDIT
I have posted this JavaFX FXML loading problem into another question found here: Root hasn't been set Error with Java 8 Eclipse