Packages

A. Sundararajan sundararajan.athijegannathan at oracle.com
Tue May 14 07:29:41 PDT 2013


Yes - it should work. importClass and few other rhino specific 
extensions have been moved to "mozilla_compat.js".

     load("nashorn:mozilla_compat.js");
     var util = Packages.java.util;
     importClass(util.HashMap);
     var m = new HashMap();

You can grab a recent jdk8 binary from 
https://jdk8.java.net/download.html. There is a shell tool called "jjs" 
in jdk/bin directory. Please do grab and play with it. And please report 
bugs/issues/problem you face with your javascript code.

-Sundar

On Tuesday 14 May 2013 07:42 PM, Frank Westlake wrote:
> From "A. Sundararajan" :
>  >     const android = Packages.android
>
>  >does not work with nashorn. But the following should
>  >work:
>
>  >     var android = Packages.android
>
>  >You can still use "Packages.android" after defining the
>  >above.
>
> Does that still work within importClass()?
>
>   var android=Packages.android;
>
>   importClass(
>     android.app.Activity
>   , android.content.Context
>   , android.graphics.Typeface
>   , android.view.Menu
>   , android.view.SubMenu
>   , android.widget.EditText
>   , android.widget.HorizontalScrollView
>   , android.widget.LinearLayout
>   , android.widget.ScrollView
>   , android.widget.TextView
>   , android.widget.Toast
>   , java.io.File
>   );
>
> Frank



More information about the nashorn-dev mailing list