I assume that you don't want to "exec" a Java program from TCL. You can
call static methods or create Java objects and call their methods. It's
quite easy once you get the environment setup.
Here is a proof of concept that I did for my team almost 2 years ago...
Java class and method:
*public* *class* Bar {
*public* *void* message(String s) {
System.out.println(*"Text From Bar: "* + s);
}
}
Tcl session to use this method:
# jtclsh
% package require java
1.3.1
% set bar [java::new Bar]
java0x1
% $bar message "This text got passed all the way in!"
Text From Bar: This text got passed all the way in!
You should be able to adapt this to your needs. Strings, boolean, and
int I believe are passed through fine so you would do something like this.
set a [$bar div2 $a]
If the bar object had a div2 method. If you want to call a static
method, look at java::call.
Hope this helps,
Scott
community help wrote:
> Hi,
>
> i'm familiarized with the getting strated section of
> the web site, but this still does not respond to my
> needs.
> What i want is to execute a java program from tcl.
> This program should modify a variable given in the tcl
> sript and later display this variable in tcl. In brief
> i want the following in my tcl script:
>
> 1. set a 10
>
> 2. execute java program that modifies the a variable
> to 5
>
> 3. puts $a (should give 5)
>
> For doing this i need to know how to execute a java
> program from tcl, and how to access a tcl variable
> from this program.
>
> Thank you
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> tcljava-user mailing list
> tcl...@li...
> https://lists.sourceforge.net/lists/listinfo/tcljava-user
>
|