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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:00:39+00:00 2026-06-08T02:00:39+00:00

ok here is my code: String[] commands = {sync && echo 3 > /proc/sys/vm/drop_caches};

  • 0

ok here is my code:

String[] commands = {"sync && echo 3 > /proc/sys/vm/drop_caches"};

Process pr = Runtime.getRuntime().exec(commands);
pr.waitFor();

And I get:

Exception in thread "main" java.io.IOException: Cannot run program "sync && echo 3 > /proc/sys/vm/drop_caches": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    at java.lang.Runtime.exec(Runtime.java:615)
    at java.lang.Runtime.exec(Runtime.java:483)
    at MyTest.main(MyTest.java:896)
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)

I copy paste the same string at the command line and I think works fine.

What is the problem? I am using Ubuntu 11.10. 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-06-08T02:00:40+00:00Added an answer on June 8, 2026 at 2:00 am

    Well, your command is using features of the shell (the && and the > redirection) , so you need to run that command in a shell. i.e. you need to run

    /bin/sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
    

    Which you can do by using this as a command

    String[] commands = {"/bin/sh", "-c" , "sync && echo 3 > /proc/sys/vm/drop_caches"};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: class Soldier { public: Soldier(const string &name, const Gun &gun);
Here's the code: string name = myName; int id = (int)_myDB.ThingTable.Where(thing => thing.ThingName ==
Here is the code: string str; cin>>str; cout<<first input:<<str<<endl; getline(cin, str); cout<<line input:<<str<<endl; The
In the following code: public class A { public A():this(null){} public A(string b){/*code here*/}
I'm writing a lexer in haskell. Here's the code: lexer :: String -> [Token]
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
here is the code public static final String DATE_TIME_FORMAT = yyyy-MM-dd kk:mm:ss; public static
Here is my code : public static void main(String[] args) { // System.setProperty( //
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is my code: new Loading.LoadTast(ctx) { @Override protected String doInBackground(Integer... params) { Looper.prepare();

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.