Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Calling .NET exec from Java

Reply
Thread Tools

Calling .NET exec from Java

 
 
olegkon
Guest
Posts: n/a
 
      05-06-2010
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.
 
Reply With Quote
 
 
 
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      05-06-2010
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/libr...25(VS.85).aspx
[2] http://support.microsoft.com/kb/830473

--
Stanimir
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      05-06-2010
On Thu, 6 May 2010 14:33:02 -0700 (PDT), olegkon <(E-Mail Removed)>
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?
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-07-2010
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


 
Reply With Quote
 
Wojtek
Guest
Posts: n/a
 
      05-07-2010
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.

--
Wojtek


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Net::SSH.exec Using the "exec" method interactively Guillermo Riojas Ruby 0 11-26-2010 05:17 PM
Runtime.exec(String[]) Doesn't Always Work, bBut Runtime.exec(String) Does Hal Vaughan Java 11 05-22-2006 04:49 PM
exec "statement" VS. exec "statement in globals(), locals() Ted Python 1 07-22-2004 08:51 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM
Backup Exec 9.1: The Backup Exec job engine system service is not responding Christian Falch Computer Support 1 06-23-2004 02:22 AM



Advertisments