Can I call a JAVA function from a .java file just like we do with .py files, like importing and then calling the python functions present in .py file from our robot script.
So can I do that with JAVA code.
I need to automate some process and that process is already automated using JAVA, so I just need to trigger it from robot script.
Any help is much appreciated
Working with java is a bit more complicated but definitely possible. There is one year old example that installs jdk to robot runtime environment and then executes java code from command line: Robot with some java code
If you need to call java functions from Robot Framework code (instead of just running the java program from command line) then you would need to use JRobot Remote server GitHub - robotframework/jrobotremoteserver: Serves remote test libraries for Robot Framework that are implemented in Java.
I don’t understand how to use this Jrobotremoteserver. Isn’t there a simpler way to use it for Java codes?
Can you give your use case? What are you trying to do?
Please note that currently our automation is using (and is tested with) CPython, that cannot use Java directly. From Robot Framework that is. (Jython is not officially supported, or tested with; see also this: robotframework/rf-5.0.rst at master · robotframework/robotframework · GitHub ).
If you just want to run “everything” Java, then openjdk is available from conda-forge. See this: Openjdk :: Anaconda.org
There is also “Java Access Bridge”, but it is different thing and does not allow function calls. If you want to learn more about that, see: RPA.JavaAccessBridge library
@jippo I am having some automation scripts that are coded in JAVA, so I wanted to call/run/trigger those JAVA scripts from my robot script just like I am doing with python scripts i.e. converting those python scripts into a function, importing .py file into .robot file and calling that function in .robot file.
It actually works fine for Python scripts but for the scripts that are in JAVA, that i am not able to do it.
If they are “complete” commands that you can run, then maybe just install that openjdk, and then control those with commands like “Run Process” from Process library keywords
Or if you want to use python, then use subprocess library to start those java “automation scripts” subprocess — Subprocess management — Python 3.10.4 documentation