jpackage                package:rJava                R Documentation

_I_n_i_t_i_a_l_i_z_e _a_n _R _p_a_c_k_a_g_e _c_o_n_t_a_i_n_i_n_g _J_a_v_a _c_o_d_e

_D_e_s_c_r_i_p_t_i_o_n:

     '.jpackage' initializes the Java Virtual Machine (JVM) for an R
     package. In addition to starting the JVM it also registers Java
     classes and native code contained in the package with the JVM.
     function must be called before any rJava functions can be used.

_U_s_a_g_e:

     .jpackage(name, jars='*', morePaths='', nativeLibrary=FALSE)

_A_r_g_u_m_e_n_t_s:

    name: name of the package. It should correspond to the 'pkgname'
          parameter of '.onLoad' or '.First.lib' function

    jars: Java archives in the 'java' directory of the package that
          should be added to the class path. The paths must be relative
          to package's 'java' directory. A special value of ''*'' adds
          all '.jar' files form the 'java' the directory.

morePaths: vector listing any additional entries that should be added
          to the class path

nativeLibrary: a logical determining whether rJava should look for
          native code in the R package's shared object or not

_D_e_t_a_i_l_s:

     '.packages' initializes a Java R package as follows: first the JVM
     is initialized via '.jinit' (if it is not running already). Then
     the 'java' directory of the package is added to the class path.
     Then '.jpackage' prepends 'jars' with the path to the 'java'
     directory of the package and adds them to the class path (or all
     '.jar' files if ''*'' was specifies). Finally the 'morePaths'
     parameter if set is passed to a call to '.jaddClassPath'.

     Therefore the easiest way to create a Java package is to add
     '.jpackage(pkgname)' in '.onLoad' or '.First.lib', and copy all
     necessary classes to a JAR file(s) which is placed in the
     'inst/java/' directory of the source package.

     If a package needs special Java parameters, '"java.parameters"'
     option can be used to set them on initialization. Note, however,
     that Java parameters can only be used during JVM initialization
     and other package may have intialized JVM already.

_V_a_l_u_e:

     The return value is an invisible TRUE if the initialization was
     successful.

_S_e_e _A_l_s_o:

     '.jinit'

_E_x_a_m_p_l_e_s:

     ## Not run: 
     .onLoad <- function(libname, pkgname) {
     .jpackage(pkgname)
     }
     ## End(Not run)

