modules/jdk.packager/src/main/native/library/common/main.cpp

Print this page

        

@@ -117,10 +117,20 @@
             Package& package = Package::GetInstance();
             Macros::Initialize();
             package.SetCommandLineArguments(argc, argv);
             platform.SetCurrentDirectory(package.GetPackageAppDirectory());
 
+            if (package.CheckForSingleInstance()) {
+                // reactivate the first instance if the process Id is valid
+                platform.reactivateAnotherInstance();
+                if (package.GetArgs().size() > 0 && platform.GetSingleInstanceProcessId() != 0) {
+                    // if user specified args, try to pass them to the first instance
+                    return RunVM(SINGLE_INSTANCE_NOTIFICATION_LAUNCH);
+                }
+                return true;
+            }
+
             switch (platform.GetAppCDSState()) {
                 case cdsDisabled:
                 case cdsUninitialized:
                 case cdsEnabled: {
                     break;

@@ -190,13 +200,12 @@
                     case cdsUninitialized: {
                         throw Exception(_T("Internal Error"));
                 }
             }
             }
-
             // Run App
-            result = RunVM();
+            result = RunVM(USER_APP_LAUNCH);
         }
         catch (FileNotFoundException &e) {
             platform.ShowMessage(e.GetMessage());
         }