This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Problem running Javafx hello world application
- From: Tony West <tonys-mailbox at hotmail dot com>
- To: "kawa at sourceware dot org" <kawa at sourceware dot org>
- Date: Wed, 7 Jun 2017 06:27:17 +0000
- Subject: Problem running Javafx hello world application
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=hotmail.com;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi,
Based on what I've seen in the mailing list, I've got the following simple Javafx application:
(module-name <org.kawa.javafx>)
(module-extends <javafx.application.Application>)
(module-export start create-button)
(module-compile-options main: #t)
;;
;;; Application
;;
(define (start (primary-stage :: <javafx.stage.Stage>)) :: <void>
(invoke primary-stage 'setTitle "Hello World!")
(let ((root-pane (<javafx.scene.layout.StackPane>))
(button (create-button
text: "Say 'Hello World'"
event-handler: (lambda (event) (format #t "Hello World!")))))
(invoke (invoke root-pane 'getChildren) 'add button)
(invoke primary-stage 'setScene (<javafx.scene.Scene> root-pane 300 250))
(invoke primary-stage 'show)))
;;
;;; Utilities
;;
(define (create-button #!key (text #f) (event-handler #f)) :: <javafx.scene.control.Button>
(let ((button :: <javafx.scene.control.Button> (<javafx.scene.control.Button>)))
(when text
(invoke button 'setText text))
(when event-handler
(invoke button 'setOnAction (object (<javafx.event.EventHandler>)
((handle (event :: <javafx.event.ActionEvent>))
(event-handler event)))))
button))
;;
;;; Main
;;
(define (main)
(invoke-static <org.kawa.javafx> 'launch))
(main)
When compiling I get the following:
E:\Work\kawa>kawa --main -C hello-world.scm
Jun 07, 2017 4:16:42 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
(compiling hello-world.scm to org.kawa.javafx)
And when I run it I get the following:
E:\Work\kawa>java org.kawa.javafx
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.IncompatibleClassChangeError: Expected static field org.kawa.javafx$frame.$main
at org.kawa.javafx.main(hello-world.scm)
... 11 more
Exception running application org.kawa.javafx
I would be really grateful if someone could point out what I am doing wrong.
Thanks.
Tony