Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:17:29+00:00 2026-05-30T17:17:29+00:00

I am developing a Java Game and it will be ran as an Application

  • 0

I am developing a Java Game and it will be ran as an Application (Not an Applet), so I would like to make a window/.exe to launch before hand, which has options (E.g. “Play”), although I am completely unsure how to do this.

I would like it to run in the same window as the C++/C# window, but if it cannot and runs by itself, that is fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:17:30+00:00Added an answer on May 30, 2026 at 5:17 pm

    Basically you need to use JNI, but not for Java to call “native” code, for the native code to bootstrap a JVM.

    #include <stdio.h>
    #include <jni.h>
    
    JNIEnv* create_vm() {
        JavaVM* jvm;
        JNIEnv* env;
        JavaVMInitArgs args;
        JavaVMOption options[1];
    
        /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */
        args.version = JNI_VERSION_1_2;
        args.nOptions = 1;
        options[0].optionString = "-Djava.class.path=c:\\projects\\local\\inonit\\classes";
        args.options = options;
        args.ignoreUnrecognized = JNI_FALSE;
    
        JNI_CreateJavaVM(&jvm, (void **)&env, &args);
        return env;
    }
    
    void invoke_class(JNIEnv* env) {
        jclass helloWorldClass;
        jmethodID mainMethod;
        jobjectArray applicationArgs;
        jstring applicationArg0;
    
        helloWorldClass = (*env)->FindClass(env, "example/jni/InvocationHelloWorld");
    
        mainMethod = (*env)->GetStaticMethodID(env, helloWorldClass, "main", "([Ljava/lang/String;)V");
    
        applicationArgs = (*env)->NewObjectArray(env, 1, (*env)->FindClass(env, "java/lang/String"), NULL);
        applicationArg0 = (*env)->NewStringUTF(env, "From-C-program");
        (*env)->SetObjectArrayElement(env, applicationArgs, 0, applicationArg0);
    
        (*env)->CallStaticVoidMethod(env, helloWorldClass, mainMethod, applicationArgs);
    }
    
    
    int main(int argc, char **argv) {
        JNIEnv* env = create_vm();
        invoke_class( env );
    }
    

    is one way of doing it, as detailed here.

    There are numerous tools which do nothing other than build the executable launcher. One such project (no experience with it, I use JNI directly) is JSmooth. Look to Freecode (formerly freshmeat) and the like for others.

    The big differences come into play when you decide you need to do more checking of the environment for proper initialization of latter JVMs, and how much verification you wish to undergo as you marshal the command line parameters from one environment to the next.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Java desktop application and would like to have an external
I'm developing a game that I will distribute using Java Web Start / JNLP.
I am developing a 3d shooter game that I would like to run on
Can anyone recommend a good Java game engine for developing simple tile-based games? I'm
I am developing a simple platform game in Java using BlueJ. Over the next
I'm developing a real time strategy game clone on the Java platform and I
What modes are the best? And any tips or tricks that make developing java
I'm developing a Java application using Eclipse. My project has two source directories that
I am developing a Java based desktop application. There are some data generated from
I'm developing a Java game and want to bundle and play a number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.