Questions about how php calls lucene (JAVA) code

Source: Internet
Author: User
Recently, I want to use a web page to display lucene search results. I can use php and javabridge on the internet. However, I can't use the example in javabridge or the class I wrote myself. Apache2.2 + php5 + mysql can now call java's own classes such as java. lang. String, but it cannot be written by yourself... In addition, javabrid has a question about how php calls lucene (JAVA) code.
Recently, I want to use a web page to display Lucene search results. Php and javabridge can be used online. However, I cannot use example in javabridge or my own classes.
Apache2.2 + php5 + mysql
Currently, you can call java classes such as java. lang. String, but you cannot write it yourself... In addition, an example in javabridge is as follows:
PHP code
  
  listFiles();  assert (!java_is_null($files));  foreach($files as $f) {    $doc = new Lucene\document\Document();    $doc->add(new Lucene\document\Field(           "name",            $f->getName(),            Lucene\document\Field::type("Store")->YES,            Lucene\document\Field::type("Index")->UN_TOKENIZED));    $writer->addDocument($doc);  }................................................

But the output is
Warning: Unexpected character in input: '\' (ASCII = 92) state = 0 in C: \ AppServ \ www \ test. php on line 5

Parse error: syntax error, unexpected T_STRING, expecting T_AS or t_paamayim_nekudoim IM or ';' in C: \ AppServ \ www \ test. php on line 5
It seems that php does not use this usage ...?
If java_require ("lucene. jar") is used, then java_require is not supported...
Let's pass by and help you... Thank you.

------ Solution --------------------
Your php version is too low to support namespaces

------ Solution --------------------
Is the environment configured...
Compile a simple php test...
$ Str = new java ("java. lang. String", "hello ");
Echo $ str;
------ Solution --------------------
It seems that I have encountered this problem, but it has not been solved yet.
------ Solution --------------------
Do you need to fill the water upstairs? I have met and haven't solved it yet!
------ Solution --------------------
Write a helloworld package into jar and put it in JavaBridge/WEB-INF/lib/restart jdk

Then in php, $ helloworld = new Java ("helloworld"); try it.

I have no problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.