Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Mac上启动控制台被抑制的Java应用程序_Java_Macos_Console - Fatal编程技术网

如何在Mac上启动控制台被抑制的Java应用程序

如何在Mac上启动控制台被抑制的Java应用程序,java,macos,console,Java,Macos,Console,我用JAVA编写了一个应用程序,并将其安装为通过launchctl(基本上是cron)运行 我遇到的问题是,每次工作启动时,我都会在菜单栏中短暂地看到“Java”,键盘控制被从我身边拿走(同样短暂,但足以让我烦恼) 如何阻止应用程序执行此操作?launchctl中有什么我可以做的吗?我知道launchctl正在启动的其他应用程序没有表现出这种行为。问题不在于Mac或launchctl。这个问题与我在应用程序中安装的一些JavaFX有关。包含“main”的类由javafx.application.

我用JAVA编写了一个应用程序,并将其安装为通过launchctl(基本上是cron)运行

我遇到的问题是,每次工作启动时,我都会在菜单栏中短暂地看到“Java”,键盘控制被从我身边拿走(同样短暂,但足以让我烦恼)


如何阻止应用程序执行此操作?launchctl中有什么我可以做的吗?我知道launchctl正在启动的其他应用程序没有表现出这种行为。

问题不在于Mac或launchctl。这个问题与我在应用程序中安装的一些JavaFX有关。包含“main”的类由javafx.application.application扩展。在我因为JavaFX“应用程序”而没有启动UI(它也可以无头运行)的情况下,无论如何都会被接管

解决方案是创建另一个扩展“应用程序”的类。我只在需要启动UI时实例化并运行该类

这是应用程序的主要功能

以前 公共类MyApp 扩展应用程序{

  @Override
  public void start(Stage primaryStage)
          throws IOException {
  ...
  }

  public static void main(String[] args)
          throws Exception {
    UIMain uiMain;
    uiMain = new UIMain();

    if (args.length == 0) {
      uiMain.run(args);
    } else {
    // Even though there is no UI being launched it still popped "Java" in the toolbar here
...
    }
  }
}
之后(可能有更好的方法)

public类UIMain
扩展应用程序{
@凌驾
公共无效开始(阶段primaryStage)
抛出IOException{
...
}
公共无效运行(字符串[]args){
发射(args);
}
}

我是否理解正确:问题不在于JAVA部分,而在于向您显示控制台而不是静默启动JAVA程序的launchctl程序?如果是这样,您可能想将问题改为:“如何在Mac上启动JAVA程序而不显示控制台?”请记住,在这里,所以我们尝试关注实际问题。很好,您发布了当前的解决方案,以及为什么它没有您想要的那么好。但也请尽可能清楚地说明预期目标。另外,欢迎使用堆栈溢出!您的问题目前有4个“暂停”投票。在5个投票时,它将获得“暂停”注意。一旦你有了包含预期目标的问题,它将进入“继续回顾”过程。
public class MyApp {

  public static void main(String[] args)
          throws Exception {
    UIMain uiMain;
    uiMain = new UIMain();

    if (args.length == 0) {
      uiMain.run(args);
    } else {
    // When this section runs I don't get the annoying Java pop in the Toolbar
... 
    }
}