Executing a simple java action on client

0
Hello, Learning mendix on my own since a week and it has been going pretty well. I have question on execution of Java actions. I have tried browsing the forum for related questions but I am unable to get my question answered clearly ...    I have modelled an app which upon a button press executes an exe file (through microflow-- Call a Java action) which is residing on the computer of the client that is opening the app. When I was trying to build this app, for testing I was able to "Publish Locally" and the button action worked well. However, When I tried publishing the app on Mendix cloud the action would not work anymore which makes sense because most likely it is trying to find the .exe file on the server.   I wanted to understand if we could get the Java action to execute from the client computer instead of the Mendix server.   Following is my java code that executes the EXE file - // This file was generated by Mendix Studio Pro. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments. package myfirstmodule.actions; import java.io.IOException; import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.webui.CustomJavaAction; public class JA_LaunchSTAR extends CustomJavaAction<java.lang.Long> { public JA_LaunchSTAR(IContext context) { super(context); } @java.lang.Override public java.lang.Long executeAction() throws Exception { // BEGIN USER CODE long result=0; String execCmd = "C:\\MyTestTemp\\"; execCmd = execCmd+"mySoftwareVersion\\bin\\"; Runtime rt = Runtime.getRuntime(); Process pr; try { pr = rt.exec(new String[] {execCmd+"myApplication.exe"}); result = pr.pid(); } catch (IOException e) { e.printStackTrace(); result = -1; } return result; // END USER CODE } /** * Returns a string representation of this action * @return a string representation of this action */ @java.lang.Override public java.lang.String toString() { return "JA_LaunchSTAR"; } // BEGIN EXTRA CODE // END EXTRA CODE }   My Microflow is as follows. Successful launch of the exe provides a Process ID which gets displays in form a information message :    Any inputs would be helpful ... Thanks
asked
2 answers
1

Java Actions only run on the server, not on the client. This means you are unable to use Java to launch any programs on the client.

 

It was only working locally for you as in this situation the client and server are running on the same machine.

 

I hope this helps.

answered
0

You can try using javascript ation to wake up the program using the link protocol

answered