私は 2 つの Java コード (FullTextIndexer.java と Indexer.java) を書きました。FullTextIndexer には関数があります。
public static StringBuilder do_exist = null;
public static String do_exist_str;
public static String a_value = new String("my_string");
public static void main(String[] args){
//... here I find "do_exist" value by using "Indexer.java" and printed it with system.out.println; which is the correct value
do_exist_str = do_exist.toString();
}
public static String get_file()
{
main(args);
return do_exist_str;
}
次に、それをコンパイルして FullTextIndexer.jar として圧縮し、WEB-INF/lib フォルダーに入れました。そして私のphpコードで:
require_once("java/Java.inc");
$session = java_session();
$t = new Java('java.lang.System');
$t=new Java("web_java.FullTextIndexer");
$gotten = java_values($t->get_file());
$a_value = java_values($t->a_value);
echo $gotten;
echo sizeof($gotten);
echo $gotten[0].$gotten[1];
file_name 文字列を取得することを期待していますが、常にサイズ 2 の {0=0, 1=0} のような配列を取得します。ただし、$a_value は正しく書き込まれます。main(args) でその値を見つけたと思いますが、後で消去し、「do_exist_str」を正しく返すことができません。この文字列を正しく取得する方法が見つかりません。どんな助けでも大歓迎です。前もって感謝します