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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:12:03+00:00 2026-06-08T15:12:03+00:00

Basically, when I type these commands in the terminal by hand, the sift program

  • 0

Basically, when I type these commands in
the terminal by hand, the sift program works and writes a .key file, but when I try to call it from my program, nothing is written.

Am I using the exec() method correctly? I have looked through the API and I can’t seem to spot where I went wrong.

public static void main(String[] args) throws IOException, InterruptedException
{           
        //Task 1: create .key file for the input file
        String[] arr  = new String[3];
        arr[0] =  "\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/siftWin32.exe\"";
        arr[1] = "<\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/cover_actual.pgm\"";
        arr[2] = ">\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/keys/cover_actual.key\"";

        String command = (arr[0]+" "+arr[1]+" "+arr[2]);

        Process p=Runtime.getRuntime().exec(command); 
        p.waitFor(); 
        BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream())); 
        String line=reader.readLine(); 

        while(line!=null) 
        { 
            System.out.println(line); 
            line=reader.readLine(); 
        } 
}
  • 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-08T15:12:04+00:00Added an answer on June 8, 2026 at 3:12 pm

    The command line you are using is a DOS command line in the format:

    prog < input > output
    

    The program itself is executed with no arguments:

    prog
    

    However the command from your code is executed as

    prog "<" "input" ">" "output"
    

    Possible fixes:

    a) Use Java to handle the input and output files

    Process process = Runtime.getRuntime().exec(command);
    OutputStream stdin = process.getOutputStream();
    InputStream stdout = process.getInputStream();
    
    // Start a background thread that writes input file into "stdin" stream
    ...
    
    // Read the results from "stdout" stream
    ...
    

    See: Unable to read InputStream from Java Process (Runtime.getRuntime().exec() or ProcessBuilder)

    b) Use cmd.exe to execute the command as is

    cmd.exe /c "prog < input > output"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there anyway to unbox an object to its real type? Basically I am
Basically if I had a mysql table with columns: id, type, content, version. There
I want to make a viewport type that basically wraps a <div> tag with
I would like to create a custom data type which basically behaves like an
I've used CCK to create a 'Travel Offer' content-type which basically just lists the
Basically I've got some structs of type Ship which are going to go on
Basically, I have an RPG-type Rails application. I'm storing skills in a skills database
I have this type which is basically a struct { int x,y,z; } that
Basically, I have: public abstract class AbstractClass { public AbstractClass( Type arg0, Type arg1,
How can I basically carry out a unique constraint on a string data-type field.

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.