# OpenRocket - Run from CLI and/or Java

### Help Support The Rocketry Forum:

#### John D

##### New Member
Hi there,

I wonder if it is possible to run a simulation in OpenRocket without the need of the GUI or the need of interact with the GUI. I am aware of simulation listeners, but these require some interaction with user interface. In brief, I want to run a simulation and get its results without interaction via mouse and integrate it as part of another software piece.

#### Buckeye

##### Well-Known Member
TRF Supporter
Rocksim has such a batch executable. I used it to "call" RockSim from my own, separate, code.

#### Yuri Achermann

##### New Member
There is some info on the wiki for scripting:

http://wiki.openrocket.info/Scripting_with_Python_and_JPype

It seems old and I never got it to work well.

What language is your project in? If you can use java, you can import the open rocket jar as a library and have full access to everything. The source is on github if you need a reference to what’s what:

https://github.com/openrocket/openrocket

This let me do everything the way I wanted to.

Good luck!
Hi, @gtg738w .

Have you been able to write a code that starts the software, loads a project and runs the simulation?
If so, could you give me at least the minimum idea of the code? What methods have you used to make everything happen and get the results?

-Yuri Achermann

#### gtg738w

##### FlightSketch - flightsketch.com
Sure, I was able to do the following:

Point to the file and load the model-
Code:
    orkFile = new File("filename.ork");
OpenRocketDocument doc = null;

try {
} catch (Exception ex) {
response.getWriter().print(ex);
}

The you can change any aspect of it and run the simulation-
Code:
    doc.getSimulation(config).getOptions().setWindSpeedAverage(windSp);
doc.getSimulation(config).getOptions().setLaunchRodAngle(launchRodAngle);

try {
doc.getSimulation(config).simulate();
} catch (SimulationException e) {
e.printStackTrace();
}

Then you can access the data from the sim-
Code:
    doc.getSimulation(config).getSimulatedData().getBranch(0).get(FlightDataType.TYPE_LONGITUDE)
Hope that helps

#### flxtrnw

##### New Member
Hi guys,
has anyone done progress with this kind of work?
With the example by @gtg738w i´m always getting Nullpointerexeptions and i'm unable to load on the doc variable.
I'm not really deep into Java so if someone have this kind of functional code for OpenRocket it would really really help me