What: JTcl
Where: ftp://ftp.gaertner.de/pub/j/jtcl-1.0.tar.gz
Description: J script library allowing access to the Tcl language.
Can invoke Tcl extensions such as Tk, allowing J programmers
to create GUI interfaces for J applications.
Updated: 09/2001
Contact: mailto: jtcl-developers@gaertner.de
----
[JTcl Interpreter] is an implementation of Tcl 8.4 in Java.
----
***JTcl port for Android***
(zdia 10/2011)
The conditions of this feasibility study were
* Linux Salix based on Slackware 13.37 with Xfce
* Android emulator with Api 8 (v. 2.2)
* javac 1.6.0_25
* Android SDK r14: http://dl.google.com/android/android-sdk_r14-linux.tgz
* JTcl-2.0.0
* Apache Ant(TM) version 1.8.2
****Create the projects folders:****
Create an Android project with something like:
======
$ android create project \
--package tcl.lang \
--activity JTcl \
--target 1 \
--path ~/Projekte/jtcl
To get info about your existing existing targets:
$ //android list targets//
Available Android targets:
id: 1 or "android-8"
Name: Android 2.2
Type: Platform
API level: 8
Revision: 3
Skins: WVGA854, WVGA800 (default), QVGA, HVGA, WQVGA432, WQVGA400
======
****Prepare for compilation****
We add an folder ''assets/'' and put as folder ''src/'' the folder ''jtcl-2.0.0/src/main/java/tcl/lang'' of Jtcl into our development directory. We have still to put the ''jtcl-2.0.0/src/main/resources/tcl/lang/library/init.tcl'' file into the ''assets/'' folder. JTcl will need it for initialization. Finally your tree hierarchy should look similar to the following:
======
|-- AndroidManifest.xml
|-- android
| |-- bin
| | |-- classes
| | |-- classes.dex
| | `-- jtcl.ap_
| `-- jtcl.jar
|-- assets
| `-- init.tcl
|-- bin
|-- build
|-- build.xml
|-- development.txt
|-- jtcl.properties
|-- libs
|-- proguard.cfg
|-- res
| |-- drawable-hdpi
| | `-- icon.png
| |-- drawable-ldpi
| | `-- icon.png
| |-- drawable-mdpi
| | `-- icon.png
| |-- layout
| | `-- main.xml
| `-- values
| `-- strings.xml
`-- src
`-- tcl
`-- lang
======
****Create the binary****
The file ''jtcl.properties'' will define our local Android environment:
======
$ cat jtcl.properties
sdk-folder=~/Projekte/jtcl
android-tools=~/Programme/android-sdk-linux_x86/tools
android-platform=~/Programme/android-sdk-linux_x86/platforms/android-8
android-platform-tools=~/Programme/android-sdk-linux_x86/platform-tools
======
The file ''Interpr.java'' in ''src/tcl/lang/''has to be modified to load the ''init.tcl'' from our ''assets/'' directory:
======
// evalResource("/tcl/lang/library/init.tcl");
evalResource("assets/init.tcl");
======
Then all is ready for ant which will be fed by the following ''build.xml'':
======
Creating output directories if needed...
bootclasspath: ${android-jar}
Building android/jtlc.jar from dir: ${android.build} ...
Converting compiled files and external libraries into ${outdir}/${dex-file}...
Packaging resources and assets...
Deleting dir: ${android.build}
======
****Preparing test:****
In the directory ''/android/bin'' we will find now the executable file ''classes.dex'' and a file ''jtcl.ap_'' with the resources compiled in, so we still have to add the executable to our ''jtcl.ap_'':
======
aapt add jtcl.ap_ classes.dex
======
The above mentioned ''assets/init.tcl'' still has to be modified. For the moment we have no tcllib files in our assets folder so we comment out autoloading of tcllib packages:
======
# set dir resource:/tcl/pkg/tcllib/library
# source $dir/pkgIndex.tcl
puts "Note: No tcllib package available"
======
Now ''jtcl.ap_'' is ready for a test:
We push ''jtcl.ap_'' to Android assumed the folder ''/data/local/bin'' has been already created by use of ''adb shell'':
======
$ adb push jtcl.ap_ /data/local/bin
======
After connection to a running Android device with ''adb shell'' you call JTcl with its entrypoint ''tcl.lang.Shell'':
======
# dalvikvm -Xbootclasspath:/system/framework/core.jar -classpath /data/local/bin/jtcl.ap_ tcl.lang.Shell
======
That's it. Sure, you can use this call inside a "Terminal emulator" Android application.
The next steps will be:
* Try to get access to the Android GUI widgets by using JTcl's java::* commands
* To make a clean Android JTcl.apk which can be launched by click executing during initialization not only init.tcl but application code, e.g. in myscript.tcl
----
[MHo] 2013-03-01: The tool '''paraffin.tcl''' doesn't work for me (Windows XP platform). The command
======
set jtclJar [ziplib::getClassLocation [java::getinterp]]
======
gives an unusable filename on windows, with a leading slash '/'. But even working around this, somethings going wrong (did not have the time to look further yet):
======
c:\Programme\jtcl-2.4.0>jtcl paraffin.tcl iskvprep6 ./iskvprep6 iskvprep6.bat .
could not open file ".\echopath": file is not a zip file
while executing
"error "could not open file \"$fileName\": file is not a zip file""
("if" then script line 2)
invoked from within
"if {[java::isnull $ent]} {
error "could not open file \"$fileName\": file is not a zip file"
}"
(procedure "ziplib::openInputZip" line 16)
invoked from within
"ziplib::openInputZip $jar"
invoked from within
"set jarin [ziplib::openInputZip $jar]"
("foreach" body line 5)
invoked from within
"foreach jar $jars {
if {! [file isfile $jar]} {
continue
}
set jarin [ziplib::openInputZip $jar]
ziplib::c..."
(procedure "mkJar" line 22)
invoked from within
"mkJar $app $srcdir $start $libdir"
(procedure "cmdLine" line 32)
invoked from within
"cmdLine"
(file "paraffin.tcl" line 79)
======
<> Application | Graphics