Calling .NET exec from Java

O

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.

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.
 
S

Stanimir Stamenkov

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
 
A

Arne Vajhøj

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
 
W

Wojtek

olegkon wrote :
Is there any limitation to the size of that parameters line on Windows
XP

Instead write out the parameters to a file, pass the file name, and
have the .NET app read the file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top