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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:47:50+00:00 2026-05-30T06:47:50+00:00

I am running shell scripts with the help of java and cygwin. When i

  • 0

I am running shell scripts with the help of java and cygwin. When i am running my code in windows xp it works fine. Now i am trying to run same code on windows 7 i am getting above error.

(java.io.IOException)java.io.IOException:
Cannot run program "sh" (in directory"c:\cygwin\bin\test"):
CreateProcess error=2.The system cannot find file specified

Why this error occurred.I have set my path for cygwin (PATH=.;c:\cygwin\bin) How to avoid this.

ProcessBuilder pb = new ProcessBuilder ();
pb.directory(new File("C:\\cygwin\\bin\\Test\\"));
File shellfile = new File("app.sh");//File name with extension
System.out.println(shellfile.getCanonicalPath());

But it is giving the output as E:\NIRAJ\example\app.sh which is in my java program. even i am setting up pb.directory to the path.

if i check System.out.print(pb.directory()); it gives me output C:\cygwin\bin\Test

  • 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-30T06:47:51+00:00Added an answer on May 30, 2026 at 6:47 am

    First try to get the path of specified file first to ensure it:

    I am not much sure but this may lead you one step ahead :

    File file = new File("app.sh");//File name with extension
    System.out.println(file.getCanonicalPath());
    

    This should print : c:\cygwin\bin\test
    Also use separator like this instead : c:\\cygwin\\bin\\test

    Hope this helps.

    UPDATE

    String myCommand = "c:\\cygwin\\bin\\test\\cygbin";
    String myArg = PATH_TO_shellscript+"app.sh";
    ProcessBuilder p = new ProcessBuilder(myCommand, myArg).start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am Executing Shell scripts in Java Using Cygwin. My Scripts are running fine
I am running a shell script on windows with cygwin in which I execute
Is it possible to have a Perl script run shell aliases? I am running
I am running GNU Emacs on Windows so entering: M-x shell launches the Windows
I am trying to build RPM for my java code.RPM build and install sections
I have the following method for running shell commands in my java applications and
I am running a shell script to execute a c++ application, which measures the
I am working on an application an have an issue about running shell command
I'm on a server running a Linux shell. I need to mail a simple
I'm running autoconf and configure sets SHELL to '/bin/sh'. This creates huge problems. How

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.