Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can executable jar return value?

 
birenshah shahbiren
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
birenshah shahbiren
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
birenshah shahbiren
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic