Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:34:51+00:00 2026-06-14T05:34:51+00:00

I am trying to run some PHP snippets from my Java application. I have

  • 0

I am trying to run some PHP snippets from my Java application.

I have seen this question:
PHP Call from Java Using Quercus

which suggests simply:

import com.caucho.quercus.QuercusEngine;

QuercusEngine engine = new QuercusEngine();
engine.setOutputStream(System.out);
engine.executeFile("src/test.php");

and I have seen http://wiki.caucho.com/Quercus%3a_Command_Line_Interface_%28CLI%29 which indicates:

QuercusEngine engine = new QuercusEngine();
engine.setIni("foo", "bar");
engine.execute("<?php var_dump(ini_get('foo')); ?>");

But on doing that, I get:

Exception in thread "main" com.caucho.quercus.QuercusErrorException: eval::1: Fatal Error: 'var_dump' is an unknown function.
        at com.caucho.quercus.env.Env.error(Env.java:6559)
        at com.caucho.quercus.env.Env.error(Env.java:6445)
        at com.caucho.quercus.env.Env.error(Env.java:6109)
        at com.caucho.quercus.expr.CallExpr.evalImpl(CallExpr.java:198)
        at com.caucho.quercus.expr.CallExpr.eval(CallExpr.java:151)
        at com.caucho.quercus.expr.Expr.evalTop(Expr.java:523)
        at com.caucho.quercus.statement.ExprStatement.execute(ExprStatement.java:67)
        at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:413)
        at com.caucho.quercus.QuercusEngine.execute(QuercusEngine.java:139)
        at com.caucho.quercus.QuercusEngine.execute(QuercusEngine.java:100)

I get the same thing for any function — strlen, strcmp, phpinfo, etc.

As described on http://quercus.caucho.com/ …

The Quercus .war file can be run on Java application servers such as
Glassfish, i.e. it can be run outside of Resin. This .war file
includes the Quercus interpreter and the PHP libraries.

I have downloaded the war file from that page (http://caucho.com/download/quercus-4.0.25.war)

and am running

$ javac -cp 'WEB-INF/lib/resin.jar;.' TestQuercus.java
$ java -cp 'WEB-INF/lib/resin.jar;.' TestQuercus

the complete file is

import com.caucho.quercus.QuercusEngine;

public class TestQuercus {

    public static void main(String[] args) throws Exception {
    QuercusEngine engine = new QuercusEngine();
    engine.setIni("foo", "bar");
    engine.execute("<?php var_dump(ini_get('foo')); ?>");
    }

}

I am able to do

java -cp 'WEB-INF/lib/resin.jar' com.caucho.quercus.CliQuercus foo.php

where foo.php includes <?php phpinfo; ?>

So how can I get from there to a working QuercusEngine?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:34:53+00:00Added an answer on June 14, 2026 at 5:34 am

    Works as below.

    import javax.script.ScriptEngine;
    import com.caucho.quercus.script.QuercusScriptEngineFactory;
    
    QuercusScriptEngineFactory factory = new QuercusScriptEngineFactory();
    ScriptEngine engine = factory.getScriptEngine();
    
    String code = "<?php $foo = strlen('abc'); print $foo; return 'yikes'; ?>";
    Object o = engine.eval(code);
    System.out.println(o);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run multiple queries on some mysql dbs from a php
I am trying to run a mysql query within some php and have the
While trying to run a string through PHP's htmlentities function, I have some cases
I am trying to set some php configuration options using .htaccess file and then
So I am trying to run some PHP code inside of Drupal (inside of
I am trying to run some code from a book . There appears to
I'm trying to run some PHP code once in a loop in bbpress (wordpress
So I'm trying to run some SQL here through PHP's PDO (which I don't
i have a problem with my PHP code, i've trying to put some information
I am trying to run some PHP pages on the command line but am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.