| MINERVA + 動的にロードされたJava拡張
この例では以下のことがわかります。
- Javaのプロパティ処理でMINERVAを拡張する方法
- MINERVAのライブラリパッケージを生成する方法
- コンパイル方法、拡張を動的にリンクする方法
- スタンドアローンとして実行する方法
- セキュリティ例外の処理方法
- 'catch/3'の使用方法
この拡張の宣言は、
property.mxtです。
アプレットラッパーは、
wrap.htmlです。
このアプレットはfile:/ URLからでは実行できません。
トップレベルのMINERVAソースプログラムは
example1.min です。
詳細は、このディレクトリの'Compile', 'Go'他のファイルを参照して下さい。
質問・問題・コメントなどは
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
minervax property
mjavac property.java
minervac example1
set prevclp=%CLASSPATH%
set CLASSPATH=%MINERVA_HOME%;%CLASSPATH%
call minervax property
call mjavac property.java
call minervac example1
set CLASSPATH=%prevclp%
#!/bin/sh
# file: Go.sh, Go
minervagui -b property -l example1
@echo off
call minervagui -b property -l example1
|