[nbj2ee] Re: NetBeans screw up command line :-)

  • From: John Yeary < >
  • To:
  • Subject: [nbj2ee] Re: NetBeans screw up command line :-)
  • Date: Fri, 30 Mar 2012 13:22:35 -0400

This is the wrong forum for these types of questions, please use the  " target="_blank"> mailing list.

____________________________

John Yeary
____________________________ 
NetBeans Dream Team
President Greenville Java Users Group
Java Users Groups Community Leader
Java Enterprise Community Leader


____________________________ 

       

"Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the gray twilight that knows not victory nor defeat."
-- Theodore Roosevelt



On Wed, Mar 28, 2012 at 3:34 PM, KKop < "> > wrote:
I am executing a batch file from the command line, from within java.

The batch file runs a ruby file on a PC on our network. Actual CL: "C:\CreateOrder.bat"  Within the batch file, I change to a mapped drive, then execute a ruby script on that mapped drive.

In Java, I run the batch file from the command line, accessed through the RunTime (see below).   This was originally developed in Eclipse, and works fine there.  I recently moved to NetBeans, and now the batch file will still run, but the command line has no knowledge of any mapped drives.

I did some tests where I have NetBeans open up a CL window, and found I can not change to, or list the contenets of any mapped network drive.

The most obvious difference between Eclipse and Netbeans is that the CL window in NetBeans opens with the NetBeans project folder as its target: C:\nbprojects\<projectname>.

So far, I have tried:
- running the commands within the batch file with UNC paths instead of mapped drives
- making sure the project folder permissions for NetBeans are the same as Eclipse
- running a CL that open a cmd window first, then execute the batch file: (cmd /c start C:\CreateOrder.bat).

I am at a loss here.  I must be missing something simple.  How can I run a CL from NetBeans, where the CL has access to my mapped drives?

Thanks.


Code:
try {
           Runtime rt = Runtime.getRuntime();
           Process pr = rt.exec(commandLine);

           BufferedReader input = new BufferedReader(new InputStreamReader(
                   pr.getInputStream()));

           BufferedReader stdError = new BufferedReader(new
                InputStreamReader(pr.getErrorStream()));

           String line = null;

           while ((line = input.readLine()) != null) {
               System.out.println(line);
           }

           // read any errors from the attempted command
           System.out.println("Here is the standard error of the command (if any):\n");
           while ((line = stdError.readLine()) != null) {
               System.out.println(line);
           }

           int exitVal = pr.waitFor();
           System.out.println("Exited with code " + exitVal);

       } catch (Exception e) {
           System.out.println(e.toString());
           e.printStackTrace();
       }









[nbj2ee] NetBeans screw up command line :-)

KKop 03/28/2012

[nbj2ee] Re: NetBeans screw up command line :-)

John Yeary 03/30/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close