title: Start Java DB server without NetBeans
body: <p>I am creating a Java APP that manages a database. I've been starting the JAVA DB server manually by right clicking - start server.  with NetBeans but since I am not going to be the one that runs the application that can't be done anymore. I need a way to start it without NetBeans. Embedded or server mode, I don't really mind. </p>
  
  <p>I've searched a lot but nothing seems to work. 
  I tried this: <a href="https://stackoverflow.com/questions/25832279/java-db-starting-server-within-application">Java DB - Starting Server within application</a></p>
  
  <pre><code>    NetworkServerControl server = new     NetworkServerControl(InetAddress.getLocalHost(),1527);
      server.start(null)    
  </code></pre>
  
  <p>I got java.net.ConnectException: Error al conectarse al servidor localhost en el puerto 1527 con el mensaje Connection refused: connect.</p>
  
  <p>I tried also starting it with the command line</p>
  
  <pre><code>    String[] command =
  {
      "cmd",
  };
  Process p = Runtime.getRuntime().exec(command);
  new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
  new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
      try (PrintWriter stdin = new PrintWriter(p.getOutputStream())) {
          stdin.println("cd C:\\Program Files\\Java\\jdk1.8.0_31\\db\\lib");
          stdin.println("java -jar derbyrun.jar server start");
      }
  int returnCode = p.waitFor();
  </code></pre>
  
  <p>Also got connection refused, (database Citas not found) so the only way it could work is this:</p>
  
  <pre><code>    String host = "jdbc:derby://localhost:1527/Citas";
      con = DriverManager.getConnection(host, username, password);    
  </code></pre>
  
  <p>But it works only if I start the server by clicking in Java DB -> start.
  Any help would be higly appreciated </p>