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 7993445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:51:08+00:00 2026-06-04T13:51:08+00:00

I am trying to run mathtext from a java program using apache-commons-exec. The problem

  • 0

I am trying to run mathtext from a java program using apache-commons-exec. The problem is I am getting different output when I run the same command from a java program and when I run it through shell.
so if run mathtext like this in the shell:

./mathtext test.png "\$\frac{{\left( {{p^2} - {q^2}} \right)}}{2}\$"

in a shell I get the perfect png
but when I run the same thing using apache-commons-exec

Map map = new HashMap();    

        map.put("target", new File(trgtFileName));
        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        Executor exec = new DefaultExecutor();
        exec.setWorkingDirectory(/*I set the working directory where the mathtext is*/);
        CommandLine cl = new CommandLine("./mathtext"); 
        cl.addArgument("${target}");
        cl.addArgument(latex);
        cl.setSubstitutionMap(map);
//      Logger.log4j.info("command is:::"+cl.toString());
        ExecuteWatchdog watchdog = new ExecuteWatchdog(5000);
        exec.setWatchdog(watchdog);
        exec.execute(cl,EnvironmentUtils.getProcEnvironment(),resultHandler);
        resultHandler.waitFor();

I get the image, not the equation but the raw TeX string 🙁

Can somebody please help me in solving the issue? I want to get the exact output.
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-04T13:51:10+00:00Added an answer on June 4, 2026 at 1:51 pm

    I figured out where the problem was:

    $ is a special character for the unix shell and not for java. So even if in the command line the input needs to escape $ like:

    "\$\frac{{\left( {{p^2} - {q^2}} \right)}}{2}\$"
    

    inside the java program I dont need to escape the ‘$’ or put ” (double quotes) at the beginning and at the end.I had to put the command like:

    $\frac{{\left( {{p^2} - {q^2}} \right)}}{2}$
    

    Hope this helps somebody 🙂

    –Shankhoneer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying run a program from a qmake .pro file which modifies the
Trying to run this little perl program from parsCit: parsCit-client.pl e1.txt Too late for
Trying to run a java test using bluecove, I got: Native Library bluecove_x64 not
Trying to run my program through java web start. I get the following exception
I am trying run a batch file from my java codes, but unfortunately I
Trying to run a program in Eclipse on Tomcat 7.0.12 and I'm getting this
Trying to run my program in FreeBSD OS, I have the following results: $
When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using
Trying to run a simple svn list svn+ssh://... from within jenkins on os X,
Trying to run a C++ program , I get segmentation faults which appear to

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.