ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> tcljava-user
tcljava-user
Re: [tcljava-user] Passing string from tcl to JAVA using tclBlend
by Mo DeJong other posts by this author
Mar 6 2006 4:47PM messages near this date
[tcljava-user] Passing string from tcl to JAVA using tclBlend | [tcljava-user] Tcl Extension
On Tue, 07 Mar 2006 00:00:08 +0000
"Mike Price" <mikeprice89@[...].com>  wrote:

>  I am currently working on a final year project where I am using tcl to 
>  interact with my JAVA program.  I have used msys to build the following 
>  programs (for Windows)
>  
>  >tcl8.4.12
>  >thread2.6.2
>  >tclBlend1.3.2
>  >Installed j2sdk1.4.2_11
>  
>  I have enabled threads for all of them and built them all without any 
>  errors.  I am then running jtclsh.bat in the command window and using the 
>  '%package require java' were it is returning 1.3.2 which is assume is 
>  correct.
>  
>  I have also developed a basic JAVA program with a simple class called 
>  'Hello' that I want to use to simply store the string sent from the tcl 
>  interpreter in a variable and then display the variable while running the 
>  java program.  Then I have run the following to try and send a variable to 
>  JAVA:
>  
>  % set jstr [java::new String "A Java String"]
>  java0x1
>  
>  Im guessing that java0x1 is the variable name that I need to reference but 
>  how do I use this variable in my JAVA program?

Well, java0x1 is a Java ref to an object. You need to pass it to a Java method
like so:

public class Test {
    static String str;

    public static void mymethod(String in_str) {
        str = in_str;
    }
}

Then you would invoke this Java method from Tcl like so:

set jstr [java::new String "A Java String"]
java::call Test mymethod $jstr

cheers
Mo DeJong

P.S.
You could also look into setting a field of a Java object using java::field.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
tcljava-user mailing list
tcljava-user@[...].net
https://lists.sourceforge.net/lists/listinfo/tcljava-user
Thread:
Mike Price
Mo DeJong

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved