Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at java_lang_Class$isAssignableFrom$1.call(Unknown Source)
at com.sun.proxy.$Proxy8.onClassInfo(Unknown Source)
Caused by: java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:268)
at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:550)
at com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(PlatformImpl.java:512)
at javafx.scene.control.Control.<clinit>(Control.java:87)
... 2 more
色々試すと、以下のような最低限のscriptでもaaaを出力もせず
全く同じerror messageを出すので、
もうGrapeでgroovyfxを読み込んでいる時点でダメなんでしょう。
@Grab('org.groovyfx:groovyfx:8.0.0')
import java.lang.*
println('aaa')
@GrabConfig(systemClassLoader=true)
@Grab('mysql:mysql-connector-java')
import groovy.sql.*
def sql = Sql.newInstance('jdbc:mysql://localhost:3306/database?useSSL=false', 'user', 'password', 'com.mysql.cj.jdbc.Driver')
sql.eachRow('SELECT * FROM table WHERE filename LIKE ?', ['%' + filename]) { r ->
...
}
import org.im4java.core.*
color = new Color(0.753, 0.302, 0.314, 0.4)
op = new IMOperation().addImage().quality(100.0).strip().addImage()
convert = new ConvertCmd()
start {
st = stage(title: 'any words OK', visible: true) {
s = scene(fill: BLACK, width: w, height: h) {
imageView(new Image(Paths.get(imageFileName).toUri().toString()))
rectangles.values().forEach { v ->
rectangle(x:v[0], y:v[1], width:v[2], height:v[3], fill:color)
}
}.snapshot(new WritableImage(w, h))
convert.run(op, SwingFXUtils.fromFXImage(s, null), imageFileName.replace('.jpg', '_.jpg'))
// ImageIO.write(SwingFXUtils.fromFXImage(s, null), 'jpg', new File(imageFileName.replace('.jpg', '_.jpg')))
}
st.close()
}