Prev: NetBeans strangeness
Next: configure Spring to use jax-ws endpoint to consume XML then produce JSON
From: olegkon on 6 May 2010 17:33 I need to write a Java program which: - collects bunch of data from the SQL Server DB (and builds command line); - calls windows executable (3rd party, black box, I assume it's written with .NET 3.5 - maybe VB or C#, but have no source code or anything) and passes it long list of parameters. My Java program will be packaged as executable JAR and reside on some Windows XP server. It will be called from job scheduler. So basically it will be a Java wrapper for that .NET exec. Could anyone help me with a sample skeleton code to call .NET executable ? Sorry, I have no experience with that, I am more of Java/Flex Web developer. So suppose I am calling that Runtime.getRuntime().exec(new String[] {"prog1" "param1" "param2"}); Is there any limitation to the size of that parameters line on Windows XP ? I have to pass a huge parameters list, something over 8Kb. Is that possible ? If not, how can we overcome it ? Any code samples ? Please advise, Oleg.
From: Stanimir Stamenkov on 6 May 2010 18:03 Thu, 6 May 2010 14:33:02 -0700 (PDT), /olegkon/: > I need to write a Java program which: > - collects bunch of data from the SQL Server DB (and builds command > line); > - calls windows executable (3rd party, black box, I assume it's > written with .NET 3.5 - maybe VB or C#, but have no source code or > anything) > and passes it long list of parameters. If it is a Windows executable there should be no difference what source language was used to compile it. > (...) > So suppose I am calling that > Runtime.getRuntime().exec(new String[] {"prog1" "param1" "param2"}); > > Is there any limitation to the size of that parameters line on Windows > XP ? > I have to pass a huge parameters list, something over 8Kb. > > Is that possible ? How is this executable currently used? You should have some docs on how to use it, right? The Windows CreateProcess [1] function has a limitation of 32767 characters for the command-line to be executed, so if the JVM implementation uses that you will get that. The command processor (cmd.exe) on the other hand has a limitation of 8191 characters [2] (so you can't test it directly from the command shell). You could at least check this: create two test classes, the first executing the second in a separate java process passing it something over 8KB command-line data, then the second one verifying what it has got. Haven't you tried it already? > If not, how can we overcome it ? If one could modify the executable being invoked one could always make it read its input from a file, if it is expected to be that big. [1] http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx [2] http://support.microsoft.com/kb/830473 -- Stanimir
From: Roedy Green on 6 May 2010 18:50 On Thu, 6 May 2010 14:33:02 -0700 (PDT), olegkon <olegkon(a)gmail.com> wrote, quoted or indirectly quoted someone who said : > >Could anyone help me with a sample skeleton code to call .NET >executable ? First of all figure out how to call your .net stuff from the "DOS" command line. Then see http://mindprod.com/jgloss/exec.html to see how to simulate it. -- Roedy Green Canadian Mind Products http://mindprod.com What is the point of a surveillance camera with insufficient resolution to identify culprits?
From: Arne Vajhøj on 6 May 2010 22:12 On 06-05-2010 17:33, olegkon wrote: > I need to write a Java program which: > - collects bunch of data from the SQL Server DB (and builds command > line); > - calls windows executable (3rd party, black box, I assume it's > written with .NET 3.5 - maybe VB or C#, but have no source code or > anything) > and passes it long list of parameters. > > My Java program will be packaged as executable JAR and reside on some > Windows XP server. > It will be called from job scheduler. > So basically it will be a Java wrapper for that .NET exec. > > Could anyone help me with a sample skeleton code to call .NET > executable ? > > Sorry, I have no experience with that, I am more of Java/Flex Web > developer. > > So suppose I am calling that > Runtime.getRuntime().exec(new String[] {"prog1" "param1" "param2"}); > > Is there any limitation to the size of that parameters line on Windows > XP ? > I have to pass a huge parameters list, something over 8Kb. > > Is that possible ? > > If not, how can we overcome it ? > > Any code samples ? The code is as it should be. (hm - actually you should be using ProcessBuilder instead) There does not seem to be any guarantees in the documentation. So I think you should test on your platform with your Java version what the implementation specific limit happens to be. (and cross your fingers that next upgrade does not change the limit) Arne
From: Peter Duniho on 6 May 2010 22:53 Stanimir Stamenkov wrote: > [...] > If one could modify the executable being invoked one could always make > it read its input from a file, if it is expected to be that big. Or alternatively, read from standard input, which you can redirect to send data directly from your Java program. It does require that you have the option of modifying the executable, but assuming you do IMHO it's a much better approach than trying to pass 8K of data on the command line. Pete
|
Next
|
Last
Pages: 1 2 Prev: NetBeans strangeness Next: configure Spring to use jax-ws endpoint to consume XML then produce JSON |