Module: HelloJavaLib

Defined in:
lib/hellojava.rb

Overview

jrubyからjavaの呼び出し

Defined Under Namespace

Classes: FuncTypes

Class Method Summary collapse

Class Method Details

.func_avoid

Systemクラス使用

Examples:

HelloJavaLib::func_a()   => 'Hello, JRuby'

This method returns an undefined value.



16
17
18
# File 'lib/hellojava.rb', line 16

def func_a()
    System.out.println("Hello, JRuby")
end

.func_bvoid

標準クラス以外の使用

Examples:

HelloJavaLib::func_b()   => 'str1'

This method returns an undefined value.



25
26
27
28
# File 'lib/hellojava.rb', line 25

def func_b()
    p JavaCallTest.str1
    return
end

.func_c(value1, value2) ⇒ void

戻り値がオブジェクトの場合

Examples:

HelloJavaLib::func_c(1, 2)   => 3

This method returns an undefined value.

Parameters:

  • value1 (int)

    value1の値

  • value2 (int)

    value2の値



37
38
39
40
41
42
# File 'lib/hellojava.rb', line 37

def func_c(value1, value2)
    hoge = Hoge.new
    calc = hoge.getCalc(value1, value2)
    p calc.add
    return
end

.func_d(fname, vals) ⇒ void

引数に二次元配列の場合

Examples:

vals = [
         [12.3, 22.5, 33.7, 44.6],
         [12.3, 22.5, 33.7, 44.6, 55.8],
       ]
HelloJavaLib::func_d("fname.jpg", vals) 
=>
 fname:fname.jpg size:2
 vals[0] size:4
 12.300000 22.500000 33.700000 44.600000
 vals[1] size:5
 12.300000 22.500000 33.700000 44.600000 55.800000

This method returns an undefined value.

Parameters:



61
62
63
64
65
66
# File 'lib/hellojava.rb', line 61

def func_d(fname, vals)
    JavaCallTest.sub1(
      fname, vals.to_java(Java::double[])
    );
    return
end