| MINERVA + Gui + Java Classes as Standalone and Applet
This example shows
- how to extend MINERVA including GUI with Java Property handling
- how to produce library packages for MINERVA
- how to compile and statically link the extension
- how to execute this as standalone and applet
- how to handle security exceptions
- how to use 'catch/3'
The declaration of the extension is
property.mxt
The applet wrapper is
wrap.html
The top level MINERVA source program is
example3.min
Refer to 'Compile', 'Go' and the other files of this directory for details.
Questions? Problems? Feedback? Please let us know!
mailto:support@ifcomputer.com
% MINERVA (c) IF Computer 1996,97
% http://www.ifcomputer.com/MINERVA mailto:support@ifcomputer.com
% PropertyExtension--------------------------------------------
java_predicates('java.util.Properties', [
create_properties = 'Properties',
properties_getProperty = getProperty(string,string),
properties_getProperty = getProperty(string),
properties_propertyNames = propertyNames,
system_getProperty = getProperty(string,string)
]).
java_predicates('java.lang.System', [
system_getProperty = getProperty(string),
system_getProperties = getProperties
]).
% MINERVA (c) IF Computer 1996,97
% http://www.ifcomputer.com/MINERVA mailto:support@ifcomputer.com
% file: example1.min
:- package(gui).
:- package(property).
main(Applet,Args) :-
textArea_create(16, 60, OutputWindow),
textComponent_setEditable(OutputWindow,false),
container_add(Applet, 'Center', OutputWindow),
textArea_getOutputStream(OutputWindow, Output),
set_output(Output),
set_error(Output),
property(Args).
property(Args) :-
write(Args),nl,flush_output,
p(system_getProperties(_)),
p(system_getProperty('my.parameter',unknownParam,_)),
p(system_getProperty('java.version',_)),
p(system_getProperty('java.vendor',_)),
p(system_getProperty('java.vendor.url',_)),
p(system_getProperty('java.home',_)),
p(system_getProperty('java.class.version',_)),
p(system_getProperty('java.class.path',_)),
p(system_getProperty('os.name',_)),
p(system_getProperty('os.arch',_)),
p(system_getProperty('os.version',_)),
p(system_getProperty('file.separator',_)),
p(system_getProperty('path.separator',_)),
p(system_getProperty('line.separator',_)),
p(system_getProperty('user.name',_)),
p(system_getProperty('user.home',_)),
p(system_getProperty('user.dir',_)),
!.
p(Goal) :-
catch(Goal,AnyError,sorry(Goal,AnyError)),
writeq(Goal), nl, flush_output,
!.
sorry(Goal,AnyError) :-
println(['Oooops: ', quoted(Goal)]),
println(['caused: ', quoted(AnyError)]),
flush_output.
#!/bin/sh
# file Compile.sh, Compile
CLASSPATH=.:$MINERVA_HOME:$CLASSPATH
export CLASSPATH
# with GUI/applet
# produce the extended Minerva top level and single added class
minervax -gui -f MinervaPropertyGui property
mjavac MinervaPropertyGui.java
mjavac property.java
# move the new top level to the default place
cp -p MinervaPropertyGui.class $MINERVA_HOME/userclasses
cp -p property.class $MINERVA_HOME/userclasses
minervac example3
@echo off
rem file Compile. bat
rem with GUI/applet
rem
rem produce the extended Minerva top level and single added class
set prevclp=%CLASSPATH%
set CLASSPATH=%MINERVA_HOME%;%CLASSPATH%
call minervax -gui -f MinervaPropertyGui property
call mjavac MinervaPropertyGui.java
call mjavac property.java
rem move the new top level to the default place
copy MinervaPropertyGui.class %MINERVA_HOME%\userclasses
copy property.class %MINERVA_HOME%\userclasses
call minervac example3
set CLASSPATH=%prevclp%
#!/bin/sh
# file: Go.sh, Go
#export CLASSPATH=.:$MINERVA_HOME:$CLASSPATH
export CLASSPATH=.:$MINERVA_HOME/userclasses:$CLASSPATH
mjava \
MinervaPropertyGui \
-c $MINERVA_HOME/minervagui.mca \
-l example3
@echo off
set PREVCLASSPATH=%CLASSPATH%
set PREVPATH=%PATH%
set CLASSPATH=.;%MINERVA_HOME%\userclasses;%MINERVA_HOME%;%CLASSPATH%
call mjava MinervaPropertyGui -c %MINERVA_HOME%\minervagui.mca -l example3
set CLASSPATH=%PREVCLASSPATH%
set PATH=%PREVPATH%
|