Help us understand the problem. What is going on with this article?

JJSコマンドでJavaScriptコード内でJavaコードを呼び出す

More than 5 years have passed since last update.

実行環境

  • MacOS X Mavericks
  • Java1.8.0_05

JJSコマンドのパスを通す

cd /usr/bin
sudo ln -s $JAVA_HOME/bin/jjs jjs

JavaScriptのファイルを作成する

collection.js
var list = java.util.Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);
var odd = list.stream().filter(function(i) {
  return i % 2 == 0;
});
odd.forEach(function(i) {
  print(">>> " + i);
}); 
  • ラムダ式で表せるインターフェースの実装に関して、JSの関数で代用できるらしい

JJSコマンド実行

$ jjs collection.js
>>> 2
>>> 4
>>> 6
>>> 8

参考

http://orablogs-jp.blogspot.jp/2014/03/oracle-nashorn-next-generation.html

kamatama_41
Javaの会社 -> Railsの会社 -> JavaとかRailsとかの会社
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした