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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:15:19+00:00 2026-06-10T03:15:19+00:00

Possible Duplicate: How to make pipes work with Runtime.exec()? Hello i wrote simple java

  • 0

Possible Duplicate:
How to make pipes work with Runtime.exec()?

Hello i wrote simple java function using exec command. This function check that font exist in system (linux). First i wrote simple bash command : identify -list font | grep -i 'Font: Times-Bold' -w and its work perfectly so i create simple program:

public abstract class SystemReader{

    public static final void checkFontExist(String name){
            String command = "identify -list font | grep -i -w \'Font: "  + name + "\'";
            Process p  =Runtime.getRuntime().exec(command);

            String lines = "";
            String resoults ="";
            BufferedReader bufferedReader = new BufferedReader(new      InputStreamReader(p.getInputStream()));
            while((line  buferedReader.readLine())!=null){
                    resoult += line + "\n";
            }

            System.out.println("RESPONSE: " + resoult);
            bufferreader.close();
    }

}

Its working but not i espect. This function return all fonts exist in my system .
Its seems that command grep is not exec ?

i try use another version of command exec() i create :

String command = {"identify -list font", "grep -i -w \'Font: " + fontName + "\'"}

but i have got error :

Exception in thread "main" java.io.IOException: Cannot run program "identify -list font ": java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at java.lang.Runtime.exec(Runtime.java:593)
    at java.lang.Runtime.exec(Runtime.java:466)

Can you give me advice what is wrong ? thanks a lot

  • 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-10T03:15:21+00:00Added an answer on June 10, 2026 at 3:15 am
    String[] cmd = {
        "/bin/sh",
        "-c",
        "identify -list font | grep -i -w \'Font: "  + name + "\'"
    };
    
    Process p = Runtime.getRuntime().exec(cmd);
    

    Will pass the command through the shell. Which is what you need since the | (pipe) command is provided by the shell and not the Operating System.

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

Sidebar

Related Questions

Possible Duplicate: How can I make XSLT work in chrome? I have this XML
Possible Duplicate: Make error: missing separator I am so stressed out by this silly
Possible Duplicate: how to make phone call by using objective c? I am trying
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: Platform independent paths in Java I make a program but it save
Possible Duplicate: Make Browser Window Blink in Task Bar Hello I want to notify
Possible Duplicate: How do I make a string with a character in it? (Java)
Possible Duplicate: How can I make setInterval also work when a tab is inactive
Possible Duplicate: java PreparedStatement Can I make the prepared statement SELECT * FROM STUDENTS
Possible Duplicate: When should I make explicit use of the this pointer? I'm wondering

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.