Merhaba
Tam olarak doğru anladığımdan emin değilim ama sanırım aradığın şey şu oluyor :
How to Access Script Objects

The eval, invokeMethod, and invokeFunction methods always return an
Object instance. For most script engines, this object is the last
value that your script calculated. So the easiest way to access
objects in the scripting environment is to return them from your
script procedures or make sure that your script evaluates to the
desired object.
Örneklerle açıklamalı şekli  :
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/

Tam ters olay yani javadan nesne js e aktarmak ta aynı dökümanın
başlarındaki kısımda bulunuyor

How to Access Java Objects From Script

JSR 223 implementations provide programming language bindings that
allow access to Java platform classes, methods, and properties. The
access mechanism will usually follow the scripting language's
conventions for native objects in that particular scripting
environment.

How do you get Java objects into the script environment? You can pass
objects into script procedures as arguments using the Invocable
interface. Alternatively, you can "put" them there: Your Java
programming language code can place Java objects into the scripting
environment by invoking a script engine's put method. This method
places key-value pairs into a javax.script.Bindings object, which is
maintained by a script engine. A Bindings object is a map of key-value
pairs that can be accessed from within an engine.


sonuç olarak sanırım bu site işini görecektir :
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/

2010/5/29 Alper KANAT <[email protected]>:
> Merhabalar,
>
> Çalıştığım bir projede JDK6 ile birlikte gelen javax.script paketini
> kullanıyorum. Yazdığım JS betiklerinin Java tarafından çalıştırılmasını ve
> sonuçlarının görünmesini sağlamaya çalışıyorum. Fakat JS nesneleri açısından
> sıkıntım var. Kod bloğu örnekleriyle açıklamaya çalışayım:
>
> JS:
>
> var hede = {'ad': 'alper', 'soyad': 'kanat'}
> java_cagrisi(hede)
>
> Bunu yaptığımda Java tarafında gönderdiğim şey [Object object] şeklinde
> görünüyor. Haliyle gönderdiğim nesnenin içindeki veriye de ulaşamıyorum.
> Aklıma JSON ile veriyi cümleye çevirip o şekilde yollamak geldi ama bu da
> hem Java tarafında, hem de JS tarafında bir JSON kütüphanesi gerektiriyor.
> Haliyle sıkışmış durumdayım epey..
>
> Bu konuda tecrübesi olan varsa tecrübelerini paylaşırsa çok sevinirim.
>
> İyi çalışmalar..
>
> ---
> Quis custodiet ipsos custodes?
>
> _______________________________________________
> Linux-programlama mailing list
> [email protected]
> https://liste.linux.org.tr/mailman/listinfo/linux-programlama
> Liste kurallari: http://liste.linux.org.tr/kurallar.php
>
>



-- 
Ömer Fadıl USTA
http://www.bilisimlab.com/
_______________________________________________
Linux-programlama mailing list
[email protected]
https://liste.linux.org.tr/mailman/listinfo/linux-programlama
Liste kurallari: http://liste.linux.org.tr/kurallar.php

Cevap