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

  • Home
  • SEARCH
  • 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 4588938
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:59:36+00:00 2026-05-21T21:59:36+00:00

I need to compile and run source code (single file), written in Python, Pascal

  • 0

I need to compile and run source code (single file), written in Python, Pascal or C, from my Java application.

I will need to know:

  • if compile process was successful
  • the return output of the compiled program

How could I accomplish that?

  • 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-21T21:59:37+00:00Added an answer on May 21, 2026 at 9:59 pm

    I have been doing the same thing..

    public String compile()
           {
               String log="";
                try {
                    String s= null;
                  //change this string to your compilers location
                Process p = Runtime.getRuntime().exec("cmd /C  \"C:\\Program Files\\CodeBlocks\\MinGW\\bin\\mingw32-g++.exe\" temp.cpp ");
    
                BufferedReader stdError = new BufferedReader(new 
                     InputStreamReader(p.getErrorStream()));
                boolean error=false;
    
                log+="\n....\n";
                while ((s = stdError.readLine()) != null) {
                    log+=s;
                    error=true;
                    log+="\n";
                }
                if(error==false) log+="Compilation successful !!!";
    
            } catch (IOException e) {
                e.printStackTrace();
            }
                return log;
           }
    
    
         public int runProgram() 
           {
               int ret = -1;
              try
                {            
                    Runtime rt = Runtime.getRuntime();
                    Process proc = rt.exec("cmd.exe /c start a.exe");
                    proc.waitFor();
                    ret = proc.exitValue();
                } catch (Throwable t)
                  {
                    t.printStackTrace();
                    return ret;
                  }
              return ret;                      
           }  
    

    This are 2 functions used in my MiDE first one used to compile. Change the address to your compilers location. and returns the log(in case compilation was failed) to see the errors.

    The 2nd one runs the compiled code. Returning the exit code to check whether it terminated correctly.

    I am not a very good java coder . i guess you can improve my code a lot better 😉 .. in case you do please inform me. And i am also looking for a answer on how to communicate with the created process

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

Sidebar

Related Questions

I need to develop a file indexing application in python and wanted to know
We have a need to generate Java source code. We do this by modeling
This code does not seem to compile, I just need to write something to
I need to know what is code compiled unit in .net. It s located
I am developing an application that will have to run on both Windows and
I am trying to compile and run a simple java class within eclipse. The
I will be hosting a java project on SVN which will need to be
Exceptions in C++ don't need to be caught (no compile time errors) by the
I need to have a process that compiles daily data into an PDF that
There are two scenarios I need to clarify: An executable compiled with .NET 3.5

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.