# JmePlatform (Luaj API)
Date: 2015-04-29

## org.luaj.vm2.lib.jme
Class JmePlatform

    java.lang.Object
      org.luaj.vm2.lib.jme.JmePlatform

    public class JmePlatform

extends java.lang.Object

The `JmePlatform` class is a convenience class to standardize how globals tables are initialized for the JME platform.

The JME platform, being limited, cannot implement all libraries in all aspects. The main limitations are

- Some math functions are not implemented, see `MathLib` for details
- Scripts are loaded via Class.getResourceAsStream(), see `BaseLib` for details
- OS functions execute(), remove(), rename(), and tmpname() vary, see `OsLib` for details
- I/O seek is not implemented, see `JmeIoLib` for details
- luajava is not available, see `LuajavaLib` for details

It is used to allocate either a set of standard globals using `standardGlobals()` or debug globals using `debugGlobals()`

A simple example of initializing globals and using them from Java is:

     Globals global = JmePlatform.standardGlobals();
     global.get("print").call(LuaValue.valueOf("hello, world"));

Once globals are created, a simple way to load and run a script is:

     LoadState.load( getClass().getResourceAsStream("main.lua"), "main.lua", globals ).call();

although `require` could also be used:

     globals.get("require").call(LuaValue.valueOf("main"));

For this to succeed, the file "main.lua" must be a resource in the class path. See `BaseLib` for details on finding scripts using `ResourceFinder`.

The standard globals will contain all standard libraries in their JME flavors:

- `Globals`
- `BaseLib`
- `PackageLib`
- `Bit32Lib`
- `TableLib`
- `StringLib`
- `CoroutineLib`
- `MathLib`
- `JmeIoLib`
- `OsLib`

In addition, the `LuaC` compiler is installed so lua files may be loaded in their source form.

The debug globals are simply the standard globals plus the `debug` library `DebugLib`.

The class ensures that initialization is done in the correct order.

See Also:
  `Globals`, `JsePlatform`

Constructor Summary
`JmePlatform()`

Method Summary
`static Globals` `debugGlobals()` Create standard globals including the `DebugLib` library.
`static Globals` `standardGlobals()` Create a standard set of globals for JME including all the libraries.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JmePlatform

    public JmePlatform()

Method Detail

### standardGlobals

    public static Globals standardGlobals()

  Create a standard set of globals for JME including all the libraries.

  Returns:
    Table of globals initialized with the standard JME libraries
  See Also:
    `debugGlobals()`, `JsePlatform`, `JmePlatform`

### debugGlobals

    public static Globals debugGlobals()

  Create standard globals including the `DebugLib` library.

  Returns:
    Table of globals initialized with the standard JSE and debug libraries
  See Also:
    `standardGlobals()`, `JsePlatform`, `JmePlatform`, `DebugLib`

Copyright © 2007-2015 Luaj.org. All Rights Reserved.