Lisp HUG Maillist Archive

Java interface examples

Hi,

I've just started working with the Java interface in LW7. Can someone point me to example code that uses the Java interface?

Thanks,

Jeremy

Re: Java interface examples

Hi,

Here is the example I've just prepared for later use:

;; load java interface module
(require "java-interface")

;; initalize java interface with default library path and custom classpath
;; (here I would like to try to use a great joda.datetime library
(lw-ji:init-java-interface :jvm-library-path t :java-class-path 
"/Users/alexeyv/Downloads/joda-time-2.8.jar")

;; import class definitions
(lw-ji:import-java-class-definitions "org.joda.time.DateTime")

;; optionally store them to the file to use later
(lw-ji:write-java-class-definitions-to-file "org.joda.time.DateTime" 
"~/Sources/lw-training/joda-datetime.lisp")

;; create an instance of the org.joda.time.DateTime class
;; it will be created with the current time in the current time zone
(setf dt (|org.joda.time|:datetime.new))

;; get current day of the week
(setf today (|org.joda.time|:datetime.getdayofweek dt))

;; get the current year
(setf current-year (|org.joda.time|:datetime.getyear dt))

Br,
/Alexey

On 28/05/15 21:05, Jeremy Jones wrote:
> Hi,
>
> I've just started working with the Java interface in LW7. Can someone 
> point me to example code that uses the Java interface?
>
> Thanks,
>
> Jeremy
>

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:33 UTC