OL Learn

Running external JAR file

Is there any simple method to get a .jar file to run as part of a workflow?

I’ve attempted running a .bat from workflow that calls the .jar but from what I can gather .jar files cannot be run as a service which is how workflow encapsulates it.

Has anyone found a simple solution to this?

Unless I am mistaken, JAR files are an archive format. Don’t you need to decompress them first? If so, have you tried the Decompress file(s) plugin found in the Action section of the Plug-in bar tab in Workflow?

Thanks for replying hamelj, unfortunately I’m not sure how this would help any.

I have written a program in java and I need to run this program using workflow, decompressing the .jar file would simply give lots of java .class files, which I don’t think workflow can interact with.

The .jar is essentially just a .exe (ish) and I need workflow to run it.

If your JAR file does not interact with the Desktop (i.e., it doesn’t display anything to the user), then you should be able to run it as a parameter to the Java.exe application. However, remember that the Workflow service runs under specific user credentials, so you have to make sure those credentials allow the java application to run. In particular, pay attention to the environment paths defined for that user, to make sure the Java application can locate all its dependencies.

Thanks for the help Phil, the problem here though is that a .jar file cannot run as a service but it seems workflow will always treat it as such.

The JAR isn’t being run as a service, it is being run from inside a service, which is a big difference.

Note for readers unfamiliar with JAR files: the JAR isn’t actually being called. Rather, it’s the Java executable that’s called, with the JAR’s name being passed as a parameter. But for the sake of this discussion, let’s just say the JAR is being called directly.

For instance, when you use the External Program task to execute CMD.exe, the CMD executable is not being run as a service, it is simply being called by the Workflow service, using the service’s credentials to run.

That said, I don’t know if Windows allows a Java application (or your specific Java application) to be called from within a service. All services run inside a special Windows Session that cannot access the desktop, but in theory, as long as the application does not attempt to interact with the desktop, it should work… but perhaps there are restrictions that I am not aware of with Java.

How would you run it from the command line? Typically you should be able to do the same from within Workflow, either by running a batch file that contains the command line, or directly from the Execute external program task.