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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:01:43+00:00 2026-05-31T10:01:43+00:00

I built a java program that runs the command jps and sees all JVMs

  • 0

I built a java program that runs the command “jps” and sees all JVMs and kills a particular JVM by extracting its id from the output of JPS command. It is working fine when I run it on the ubuntu terminal. But then I wrote a script in bash to ssh that machine from other machine and run this program there.

ssh $host "java -cp daemon.jar JVMname;"

Now here comes the problem.

Exception in thread "main" java.io.IOException: Cannot run program "jps": error=2, No     such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) at runtime.daemon.halt.main(halt.java:19)
Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method)  at  java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)

If I go to the the machine myself and run this same command it works. I do not want to switch to exec solution.

Any ideas
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-31T10:01:44+00:00Added an answer on May 31, 2026 at 10:01 am

    This isn’t a Java issue per se, it’s down to the difference in your environment in both cases. Specifically, when you run interactively, your $PATH variable contains the directory for jps, whereas in the latter case via SSH it doesn’t.

    Have a look at the .bash_profile and .bashrc files on the remote machine – I suspect the path will be set in the .bash_profile file, which isn’t executed for non-login shells (such as your SSH invocation that runs a single command). If you set the path correctly in .bashrc, then your current invocation should start working.

    (Note this assumes you’re using bash for a shell, though most other shells have a similar distinction between the login shell and non-login shell init files.)

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

Sidebar

Related Questions

I have built a small program for school that runs perfectly when i run
On Mac OSX 5.8 I have a Java program that runs at 100% CPU
Is there a built in Java code that will parse a given folder and
I have built a Java application that has some dependencies (~10). I would like
I'm looking for a Java built-in data structure that would be the best at
I have an existing system built in Java we currently expand that by adding
I'm working on a Java program that needs to send an image (preferably in
I built this program that works with files. Since I made it for a
I once built a program in php that used very specific regular expressions to
I am trying to create a Jenkins job that restarts a program that runs

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.