<bdo id='3YfPE'></bdo><ul id='3YfPE'></ul>
  • <tfoot id='3YfPE'></tfoot>
      <legend id='3YfPE'><style id='3YfPE'><dir id='3YfPE'><q id='3YfPE'></q></dir></style></legend>

      <i id='3YfPE'><tr id='3YfPE'><dt id='3YfPE'><q id='3YfPE'><span id='3YfPE'><b id='3YfPE'><form id='3YfPE'><ins id='3YfPE'></ins><ul id='3YfPE'></ul><sub id='3YfPE'></sub></form><legend id='3YfPE'></legend><bdo id='3YfPE'><pre id='3YfPE'><center id='3YfPE'></center></pre></bdo></b><th id='3YfPE'></th></span></q></dt></tr></i><div id='3YfPE'><tfoot id='3YfPE'></tfoot><dl id='3YfPE'><fieldset id='3YfPE'></fieldset></dl></div>

      1. <small id='3YfPE'></small><noframes id='3YfPE'>

        JavaExe 和 Java 应用程序作为与桌面交互的 Windows 系统服务

        JavaExe and Java application as windows system service interactive to desktop(JavaExe 和 Java 应用程序作为与桌面交互的 Windows 系统服务)
          <tbody id='NkAda'></tbody>
        <i id='NkAda'><tr id='NkAda'><dt id='NkAda'><q id='NkAda'><span id='NkAda'><b id='NkAda'><form id='NkAda'><ins id='NkAda'></ins><ul id='NkAda'></ul><sub id='NkAda'></sub></form><legend id='NkAda'></legend><bdo id='NkAda'><pre id='NkAda'><center id='NkAda'></center></pre></bdo></b><th id='NkAda'></th></span></q></dt></tr></i><div id='NkAda'><tfoot id='NkAda'></tfoot><dl id='NkAda'><fieldset id='NkAda'></fieldset></dl></div>
          <legend id='NkAda'><style id='NkAda'><dir id='NkAda'><q id='NkAda'></q></dir></style></legend>
          <tfoot id='NkAda'></tfoot>

          • <bdo id='NkAda'></bdo><ul id='NkAda'></ul>

          • <small id='NkAda'></small><noframes id='NkAda'>

                • 本文介绍了JavaExe 和 Java 应用程序作为与桌面交互的 Windows 系统服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  请求:

                  这是我所在地区的 Java 开发人员面临的一个非常常见的问题.我真的被困了很多天.搜索并尝试了很多,阅读文档.阅读所有与 JavaExe 相关的 stackoverflow 问题.请仅在您以前做过类似的事情并有全面答案的情况下回复.我会非常感谢社区!

                  This is a very common problem faced by Java devs in my locale. I am really stuck for many days on this. Searched and tried a lot, read the docs. read ALL the stackoverflow questions related to JavaExe. Please only reply if you have done similar thing before and have a comprehensive answer. I would be really grateful to the community!

                  塞纳里奥:

                  我正在使用 JavaExe 将应用程序作为 系统服务 在桌面 交互式 功能中运行.确切地说,我有一个捕获桌面屏幕截图的应用程序.我希望它在任何用户登录时运行(以管理员身份),因此没有人可以阻止它.

                  I am using JavaExe to run an application as system service in desktop interactive capability. To be exact I have an application that captures screenshots of desktops. I want it to run (as admin) on any user login so no one can stop it.

                  我有一个 myapp.jar、settings.txt 和一个 lib 目录.

                  I have a myapp.jar, settings.txt and a lib dir.

                  我搜索了很多,发现 JavaExe 有效(通过观看它的示例)

                  I have searched alot and found JavaExe works (by watching its examples)

                  如果有人有更好的方法.请说明.

                  If anyone has a better way. Please state so.

                  问题:

                  根据我的研究,

                  1. 你必须创建一个类似.exe 的.properties 文件,并在该文件中写入"RunType = 1".

                  您在主类中定义了一个静态方法:serviceInit()

                  you define a static method in your main class : serviceInit()

                  我需要放置任何类或引用/导入吗?怎么样?

                  Do I need to place any class or reference/import? How?

                  我下面的代码 works 作为独立的 .jar 和 javaExe.exe.

                  My code below works as stand alone .jar and in javaExe.exe too.

                  它现在提供系统服务并由SYSTEM用户运行.但它不能与桌面交互.即它没有显示任何 GUI.

                  It now does makes a system service and runs by as SYSTEM user. but It is NOT interactive to desktop. i.e its not showing any GUI.

                  package temp;
                  
                  import java.util.logging.Level;
                  import java.util.logging.Logger;
                  import javax.swing.JOptionPane;
                  
                  
                  public class Temp {
                  
                  
                      /**
                       * @param args the command line arguments
                       */
                      public static void main(String[] args) {
                  
                  
                            serviceInit();
                  
                      }
                  
                      public static boolean serviceInit(){
                  
                          new Thread(){
                              public void run(){
                                  Integer i = 0;
                                  while(i < 999999999){
                                      JOptionPane.showMessageDialog(null,i);
                                      i++;
                  
                                  }
                              }
                          }.start();
                  
                          return true;
                     }
                  
                  
                  
                  
                  }
                  

                  而且我认为将 .jar、lib 目录和 settings.txt 捆绑到一个 .exe 中是不可能的?

                  And I dont think that bundling the .jar, lib directory and settings.txt into one .exe is possible?

                  推荐答案

                  你应该有:

                  public class MyApp_ServiceManagement
                  {
                      static boolean isMsgToDisplay = false;
                  
                      /////////////////////////////
                      public static boolean serviceInit()
                      {
                          (new Thread()
                          {
                              public void run()
                              {
                                  for(int i=0;i < 6;i++)
                                  {
                                       try { sleep(5*1000); }
                                       catch(Exception ex) {}
                  
                                       isMsgToDisplay = true;
                                  }
                              }
                          }).start();
                  
                          return true;
                      }
                  
                      /// is Data ready to be send to the UI ?
                      public static boolean serviceIsDataForUI()
                      {
                          return isMsgToDisplay;
                      }
                  
                      /// Data to be send to the UI
                      public static Serializable serviceDataForUI()
                      {
                          isMsgToDisplay = false;
                          return "hello, I am an interactive Service";
                      }
                  }
                  

                  对于 UI 部分:

                  public class MyApp_TaskbarManagement
                  {
                      /// To show (or not) the icon in tray
                      public static boolean taskIsShow()
                      {
                          return false;
                      }
                  
                      /// Receive the message from Service
                      public static void taskDataFromService(Serializable data)
                      {
                          JOptionPane.showMessageDialog(null, data);
                      }
                  
                      /// descr of UI
                      public static String[] taskGetInfo()
                      {
                          return new String[]
                              {
                                  "UI part of Service"
                              };
                      }
                  }
                  

                  这篇关于JavaExe 和 Java 应用程序作为与桌面交互的 Windows 系统服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                    <legend id='zCeH9'><style id='zCeH9'><dir id='zCeH9'><q id='zCeH9'></q></dir></style></legend>

                    <small id='zCeH9'></small><noframes id='zCeH9'>

                      • <bdo id='zCeH9'></bdo><ul id='zCeH9'></ul>

                              <tbody id='zCeH9'></tbody>
                            <i id='zCeH9'><tr id='zCeH9'><dt id='zCeH9'><q id='zCeH9'><span id='zCeH9'><b id='zCeH9'><form id='zCeH9'><ins id='zCeH9'></ins><ul id='zCeH9'></ul><sub id='zCeH9'></sub></form><legend id='zCeH9'></legend><bdo id='zCeH9'><pre id='zCeH9'><center id='zCeH9'></center></pre></bdo></b><th id='zCeH9'></th></span></q></dt></tr></i><div id='zCeH9'><tfoot id='zCeH9'></tfoot><dl id='zCeH9'><fieldset id='zCeH9'></fieldset></dl></div>
                          1. <tfoot id='zCeH9'></tfoot>