有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何在php中从java函数中获取字符串

我已经编写了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];

我希望得到我的文件名字符串,但是我总是得到一个像{0=0,1=0}这样大小为2的数组。 但它正确地写入了$a_值。 我猜它会在main(args)中找到它的值,但会在之后删除,并且不能正确返回“do_exist_str”。 我找不到正确获取此字符串的方法。任何帮助都将不胜感激。提前谢谢


共 (0) 个答案