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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:18:24+00:00 2026-05-18T08:18:24+00:00

I have a HelloWorld.java located on my server, and I’d like to compile this

  • 0

I have a HelloWorld.java located on my server, and I’d like to compile this program using “javac” within php.

So, I have the following code

<?php 
exec("javac HelloWorld.java", $array); 
print_r($array);
?>

And the output is

Array ( )

What am I doing wrong? javac.exe is located in the same spot this php file is.

Any help would be much appreciated. 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-05-18T08:18:24+00:00Added an answer on May 18, 2026 at 8:18 am

    This should surely help you

    http://www.ibm.com/developerworks/opensource/library/os-php-commandline/index.html

    The output parameter gets only standard output, if you need error output too, don’t forget to redirect it.
    If the output parameter is still empty after an execution and if it shouldn’t, you must be in this case.

    http://us.php.net/manual/en/function.exec.php

    Or

    use passthrough. It looks similar to execute.

    Read the links provided.

    Something like this:

    <?php
    # ...
    # (function stuff)
    ob_start();
    passthru("php myscript.php, $result");
    $content_grabbed=ob_get_contents();
    ob_end_clean();
    
    if($result=0){
     echo '<div>',$content_grabbed,'</div>';
    }_
    # (more function stuff)
    # ...
    ?>
    

    I don’t know about drawbacks that this method might have. Maybe and increased overhead? Anyway I was happy to circumvent the problem with it.

    http://us.php.net/manual/en/function.passthru.php

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

Sidebar

Related Questions

I have a simple web service operation like this one: [WebMethod] public string HelloWorld()
I have create following java file,compile it and got .class file. import java.io.*; import
For example, I know I have a java file named HelloWorld.java. I don't like
We have tried to create sample webservices helloworld in Java using Jersey and Tomcat
I have a string like this: String A: [ 12234_1_Hello'World_34433_22acb_4554344_accCC44 ] I would like
I installed Java 1.7.0 in the following folder C:\Program Files\Java . My operating system
Does anyone have a good tutorial on Java + Cucumber integration? I've begun using
I have the following test code (based on standard monodroid HelloWorld) namespace TestGREF {
i have jogl in the path and this program works fine until i include
i want to use the Java program in JSP. i have created java program

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.