NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

NetBeans screws up command line :-)

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
KKop



Joined: 28 Mar 2012
Posts: 4

PostPosted: Wed Mar 28, 2012 7:34 pm    Post subject: NetBeans screws up command line :-) Reply with quote

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();
        }
Back to top
jyeary



Joined: 21 Oct 2008
Posts: 606
Location: Simpsonville, SC

PostPosted: Fri Mar 30, 2012 5:42 pm    Post subject: Re: NetBeans screw up command line :-) Reply with quote

This is the wrong forum for these types of questions, please use the
Back to top
KKop



Joined: 28 Mar 2012
Posts: 4

PostPosted: Fri Mar 30, 2012 5:53 pm    Post subject: Reply with quote

I'd gladly move it to the right forum, but you didn't say which one Smile
Back to top
KKop



Joined: 28 Mar 2012
Posts: 4

PostPosted: Mon Apr 02, 2012 12:56 pm    Post subject: Reply with quote

Anyone?

My question basically boils down to:

- how to start a CL from NetBeans that recognizes mapped drives -

Thanks
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo