code: public static void main(String[] args) {
          File dir = null;
  
          System.out.println("checkLocalRserve: " + checkLocalRserve());
          try {
              RConnection c = new RConnection();
              //c.eval("cat('123')");
              dir = new File(c.eval("getwd()").asString());
              System.err.println("wd: " + dir);
              //c.eval("flush.console <-function(...) return;"); // will crash without that...
              c.eval("download.file('https://www.r-project.org/',paste0(getwd(),'/log.txt'))");
              c.shutdown();
          } catch (Exception x) {
              x.printStackTrace();
          }
  
          if (new File(dir, "log.txt").exists()) {
              System.err.println("OK: file exists");
              if (new File(dir, "log.txt").length() > 10) {
                  System.err.println("OK: file not empty");
              } else {
                  System.err.println("NO: file EMPTY");
              }
          } else {
              System.err.println("NO: file DOES NOT exist");
          }
      }
docs: just a demo main method which starts Rserve and shuts it down again
  
  @param args ...