Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (736)
Games in Android Showcase (223)
games submitted by our members
Games in WIP (813)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: princec (posted 2013-03-27 04:47:58, viewed 326 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137  
/*
 * Ultratron launcher
 */

#include "launcher.h"

#if defined(STEAM)
#define EXTRA_STEAM_LIBS ";steampuppy.jar"
#else
#define EXTRA_STEAM_LIBS
#endif

#if defined(INSTALLER)
#define ARGUMENTS "-Djava.class.path=installer.jar;lzma.jar"
#define OPTIONS 17
#define MAIN_CLASS INSTALLER_CLASS
#else
#define ARGUMENTS "-Djava.class.path=Ultratron.jar;data-" AFFILIATE ".jar;gfx.jar;fonts.jar;images.jar;music.jar;fx-mono.jar;fx-stereo.jar;gamecommerce.jar;spgl-lite.jar;common.jar;jorbis.jar;lwjgl.jar;lwjgl_util.jar;jinput.jar;sqlite.jar;steampuppy-public.jar" EXTRA_STEAM_LIBS
#define OPTIONS 13
#define MAIN_CLASS LAUNCHER_CLASS
#endif

static JNIEnv *env;
static jobject jobj = 0;
static JavaVM *vm;

/*
 * Display an error message
 */
void messageBox(char * message) {
   MessageBox(NULL, message, APP_TITLE, MB_OK);
}

int startup(LPSTR lpCmdLine);

typedef jint (APIENTRY * CreateJavaVMPROC) (JavaVM **pvm, void **penv, void *args);

int main(const int& argc, const char ** argv)
{
   return startup((LPSTR) argv);
}

/*
 * Invoke our embedded JVM
 */
int WINAPI WinMain
(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
) 
{
   return startup(lpCmdLine);
}


int startup(LPSTR lpCmdLine)
{
    jint res;
   jclass cls;
    jmethodID mid;
    jobjectArray args;
    JavaVMInitArgs vm_args;
   JavaVMOption options[OPTIONS];

   options[0].optionString = ARGUMENTS;
   options[1].optionString = "-Xms64m";
   options[2].optionString = "-Xmx256m";
   options[3].optionString = "-XX:MaxGCPauseMillis=3";
   options[4].optionString = "-Xincgc";
   options[5].optionString = "-Dorg.lwjgl.util.NoChecks=true";
   options[6].optionString = "-Dnet.puppygames.applet.Launcher.resources=resources-" AFFILIATE ".dat";
   options[7].optionString = "-Dnet.puppygames.applet.Game.gameResource=game." AFFILIATE;
   options[8].optionString = "-XX:+TieredCompilation";
   options[9].optionString = "-XX:Tier2CompileThreshold=70000";
   options[10].optionString = "-XX:CompileThreshold=1500";
   options[11].optionString = "-XX:+DoEscapeAnalysis";
   options[12].optionString = "-XX:+AggressiveOpts";
#if defined(INSTALLER)
   options[13].optionString = "-Dnet.puppygames.installer.updater.GameUpdater.gameName=Ultratron";
   options[14].optionString = "-Dnet.puppygames.installer.updater.GameUpdater.indexURL=http://downloads.puppygames.net/ultratron/update-windows-" AFFILIATE ".index";
   options[15].optionString = "-Dnet.puppygames.installer.updater.GameUpdater.mainClass=net.puppygames.applet.Launcher";
   options[16].optionString = "-Dnet.puppygames.installer.updater.GameUpdater.displayTitle=Ultratron";
#endif

   HMODULE jvmdll = LoadLibrary("bin\\server\\jvm.dll");
   if (jvmdll == NULL) {
      messageBox("Failed to load Java dll.");
      return 1;
   }

   vm_args.version = JNI_VERSION_1_6;
    vm_args.options = options;
   vm_args.nOptions = OPTIONS;
    vm_args.ignoreUnrecognized = FALSE;

   CreateJavaVMPROC CreateJavaVM = (CreateJavaVMPROC) GetProcAddress(jvmdll, "JNI_CreateJavaVM");

   res = CreateJavaVM(&vm, (void **)&env, &vm_args);

    if (res < 0) {
      messageBox("Failed to create Java virtual machine.");
      return 2;
    }

    // Get the main class
   cls = env->FindClass(MAIN_CLASS);

    if (cls == 0) {
        messageBox("Failed to find the main class.");
      return 3;
    }

    // Get the method ID for the class's main(String[]) function.
    mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");

    if (mid == 0) {
        messageBox("Failed to find the main method.");
      return 4;
    }

   // Pass a single string commandline arg
   jstring arguments = env->NewStringUTF(lpCmdLine);
    args = env->NewObjectArray(1, env->FindClass("java/lang/String"), NULL);
   env->SetObjectArrayElement(args, 0, arguments);

    // Run the main class...
    env->CallStaticVoidMethod(cls, mid, args);
   bool ok = true;
    if (env->ExceptionOccurred()) {
      ok = false;
      env->ExceptionDescribe();
    }
    vm->DestroyJavaVM();
   return ok ? 0 : 5;
}





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 
cybrmynd (120 views)
2017-08-02 12:28:51

cybrmynd (144 views)
2017-08-02 12:19:43

cybrmynd (138 views)
2017-08-02 12:18:09

Sralse (154 views)
2017-07-25 17:13:48

Archive (624 views)
2017-04-27 17:45:51

buddyBro (733 views)
2017-04-05 03:38:00

CopyableCougar4 (1260 views)
2017-03-24 15:39:42

theagentd (1239 views)
2017-03-24 15:32:08

Rule (1216 views)
2017-03-19 12:43:22

Rule (1268 views)
2017-03-19 12:42:17
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!