Previous Next        Current Page: NeXtMidas User's Guide / Running NeXtMidas Independently
back
FAQs   
Release Information   
Getting Help   
Basic Concepts   
Result Parameters   
XML Support   
Files   
System Operation   
Macros   
Java WebStart   
Graphics   
X-Midas Interoperability   
Third-Party Compatibility   
Installation and Customization   
Running NeXtMidas Independently   
Glossary   


Running NeXtMidas Without a Midas Context (Directly in Java code)

It is possible to run NeXtMidas commands outside of a NeXtMidas application or NeXtMidas command prompt.

The nxm.sys.lib.NeXtMidas class allows users to specify setup arguments, such as option trees and the NeXtMidas PATH, and run a single command or multiple commands in sequence. The arguments start with a hyphen("-") and follow a -<key>=<value> format.

NOTE: nxm.sys.lib.NeXtMidas should be treated as a singleton, since various underlining NeXtMidas framework classes (such as the NeXtMidas Shell) uses global variables (such as the PATH, AUXes, etc). Otherwise multiple instances can step over each other and cause undefined behavior.

Examples:

Outside a Java application:
java -classpath $NMROOT nxm.sys.lib.NeXtMidas -cmd="plot Sunset.jpg" 
or inside a Java application:
  String[] args = {"-aux.write=HOME", "-aux.read=HOME|DAT", "-cmd=home test sys", "-script=nxm.sys.test.test_plot.mm"};
  NeXtMidas.main(args);

You can also instantiate the NeXtMidas class for running multiple commands

  String[] myArgs = {"-aux.1=/midas/data1/+1/", "-aux.write=HOME", "-aux.read=HOME|DAT|RAM|1"};
  NeXtMidas nxm = new NeXtMidas(myArgs);
  nxm.runCommand("plot/bg sinewave.prm");
  nxm.runCommand("plot/bg world.shp|cities.prm");

If you wish, you can direct graphical output to an existing MidasDisplay

  nxm.runCommand("plot/bg world.shp", myFirstMidasDisplay);
  nxm.runCommand("plot/bg apenny.prm", mySecondMidasDisplay);
  Command cmd3 = nxm.runCommand("list2/bg apenny.prm", myThirdMidasDisplay);
  // System.out.println("executed command's ID = "+cmd3.getID());
Supported arguments (options):
  -aux.<auxname>=<custom_aux>  Set a user-defined AUX (e.g. -aux.mydata=/home/data/)
  -aux.read=<read_aux>         Set the read AUX list
  -aux.write=<write_aux>       Set the write AUX
  -cmd=<command>               Alias for -command
  -command=<command>           A command with any necessary arguments to execute
  -debug                       Set debug to 'deprecate'
  -debug=<value>               Set debug to masked value (deprecate, trace, supertrace, etc.)
  -encoding                    Set the type of Escape Char encoding to null
  -encoding=<type>             Set the type of Escape Char encoding ("NONE", "Percent", or "%")
  -headless                    Set HEADLESS to true
  -headless=[true|false]       Set HEADLESS to true or false
  -help, -h, -?                Print this usage help message
  -nonative                    Set NONATIVE to true (disable native code)
  -nonative=[true|false]       Set NONATIVE to true or false (enable native code)
  -path=<path>                 Set the PATH
  -prompt                      Create a NeXtMidas 'nM>' terminal prompt (executed after commands)
  -script=<macro>              Run a NeXtMidas macro from HOMEPATH, unless using absolute path, "nxm" dot syntax, or a URL.
  -shell                       Open a NeXtMidas SHELLGUI (or terminal prompt if graphics is not available)
  -verboseversion, -vv         Print out the verbose version of NeXtMidas, Java, OS, etc.
  -version                     Print out the NeXtMidas version

For more information and examples, check the API for nxm.sys.lib.NeXtMidas.java or the test application for it, nxm.sys.test.TestNeXtMidas.java


back