________________________________________________________________________

This file is part of Logtalk <https://logtalk.org/>  
Copyright 1998-2022 Paulo Moura <pmoura@logtalk.org>  
SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
________________________________________________________________________


% start by loading the example:

| ?- logtalk_load(jpl(loader)).
...


% get the Java version by using the getProperty/1 static method:

| ?- java('java.lang.System', Version)::getProperty('java.version').

Version = '1.7.0_51'
yes


% get the value of the "pi" constant by accessing the 'PI' class field:

| ?- java('java.lang.Math')::get_field('PI', Pi).

Pi = 3.141592653589793
yes


% create a new instance of ArrayList and add some elements to it:

| ?- java('java.util.ArrayList')::new(ArrayList), java(ArrayList)::(add('Paulo'), add('Carlos'), add('Helena')).
yes


% round-trip conversion:

| ?- java::terms_to_array([x,[1,a,7,[y,z]],k,[],3.14,foo(bar)], Array), java::array_to_terms(Array, List).
Array = @'J#00000140321793636416',
List = [x, [1, a, 7, [y, z]], k, [], 3.14, foo(bar)].
yes


% some GUI examples, adapted from the JPL distribution examples

| ?- color_chooser::color(Color).

Color = @'J#00000140727398998200'
yes

| ?- flags_table::display.
yes

| ?- jlist::display.
yes

| ?- text_entry::text(Text).
Text = ...
yes


% run some benchmarks comparing plain JPL calls with calls to Logtalk's thin
% abstraction layer:

| ?- benchmarks::run.
...

