Forums Register Login

Can executable jar return value?

+Pie Number of slices to send: Send
Hi All,

I have an executable jar, which is supposed to return a String value.
First of all, Is it possible?? If yes, how??

This jar will be called from VBScript program and I need the returned a string value to be used in VB Script.

Any help in this regrads will be appreciated.

Thanks,
Biren
+Pie Number of slices to send: Send
 

birenshah shahbiren wrote:I have an executable jar, which is supposed to return a String value.
First of all, Is it possible?? If yes, how??


Don't think so. Java programs can return numeric values, but these are generally used to indicate an error; and I certainly wouldn't use them for business logic.

What it (and any program, Java or otherwise) CAN do is write a String to a stream, such as stdout.

Winston
+Pie Number of slices to send: Send
Thanks Winston!

Writing it to a file is kind of last option, as jar file is going to return decrypted password.
Preference would be to store in cache or session.

Now the question arises, As application is not using any application/web server, is it possible to store thevalue in cache/session?
Second one, is registery a good option to store decypted password?
+Pie Number of slices to send: Send
 

Winston Gutkowski wrote:
Don't think so...
Winston


Actually yes. Executable and jar are red herrings.
Consider it as any other library on your class path, on whose class(es) you can invoke method(s) and that will return values.
+Pie Number of slices to send: Send
I think Winston is assuming, as I am, that the JAR file will contain the Java program that is executed via the shell in VBScript, in which case: no you can't
+Pie Number of slices to send: Send
Thank you for quick response, however it will be really great if any of you can give me the way to write a java program, which returns a String value when jar is called from VBScript
I believe, only that class from executable jar will be called which contains main() method.

Below is the working syntax for VBScript calling jar file:
createobject("wscript.shell").run "java -jar vbcall.jar " & dbPassword & " CipherText ", 0, True

I am still wating for the response, on possibility of jar returning a String value?
+Pie Number of slices to send: Send
It can't return a String. The only return value of the java executable is an integer (generally zero for successful completion, non-zero in case of error).

As someone has already suggested, what you can do is write a Java program that will write to stdout - using System.out.println() statements. So you need a way of capturing that output in your VBScript. I'm sure that's possible, though I've no idea how because I don't know VBScript. But a quick Google gives a few useful looking links, for example: http://www.codescript.co.uk/run_command_capture_output.htm.
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4781 times.
Similar Threads
Executing jar - when java -jar fails
Need an executable jar to return a value
java.lang.ClassNotFoundException: COM.ibm.db2.jdbc.app.DB2Driver
creating win exe file from java
about jar file
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:32:13.