如何在单独的控制台上使用一种配置启动多个 Java 程序(使用 Eclipse)

发布于 2024-07-08 17:58:11 字数 263 浏览 7 评论 0原文

我正在使用一个具有多个组件的 Java 程序(目前使用 Eclipse 和 Ant)。

有没有一种方法可以通过一个启动配置启动多个程序? 我有一个 Ant 目标可以完成这项工作(启动多个程序),但我想做一些事情:

  • 我想使用 Eclipse 调试程序,因此需要启动 Eclipse。
  • 我想在不同的控制台上查看程序的输出。

另外,使用单独的控制台和/或调试“一键式”启动多个 Java 程序的其他方法也可以。

I'm working with a Java program that has multiple components (with Eclipse & Ant at the moment).

Is there some way to start multiple programs with one launch configuration? I have an Ant target that does the job (launches multiple programs) but there are things I would like to do:

  • I would like to debug the programs with Eclipse, hence the need for Eclipse launch.
  • I would like to see the outputs for the programs at separate consoles.

Also other ways to launch multiple Java programs "with one click" with separate consoles and/or debugging would be ok.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

没有心的人 2024-07-15 17:58:11

['multiple launch part':]

如果您有一个 ant 启动配置,可以执行您想要的操作,您可以随时将其转换为调用 ant 的 java 启动器。

Main Class: org.apache.tools.ant.Main

-Dant.home=${resource_loc:/myPath/apache_ant} 
-f ${resource_loc:/myProject/config/myFile-ant.xml}

然后,您可以将这个 ant 会话作为常规 Java 应用程序启动,并使用所有 Eclipse 调试工具。

添加到“用户条目”部分中的类路径(在您的项目和默认路径之前):

  • ant.jar
  • ant-launcher.jar

[多个控制台部分]

可能的解决方案可能是确保您的 ant启动器实际上在自己的 JVM 进程中启动不同的应用程序(每个应用程序一个 javaw.exe),

这样,您就可以使用 本机 Eclipse 控制台在不同进程之间切换

控制台视图清楚地将输出与每个不同的“进程”分开,并将它们保存在多个“缓冲区”中。 控制台有一个内置的“切换”功能,可以自动切换视图以显示最后执行输出的进程的缓冲区,但是您可以轻松地将显示切换到您想要查看的任何“进程缓冲区”。

要切换控制台“缓冲区”显示,只需单击控制台视图标题栏右侧第四个工具栏按钮旁边的黑色“向下箭头”(该按钮
类似于电脑屏幕):
这将显示一个弹出菜单,列出所有活动进程缓冲区的“名称”,前面带有“订单号”。
当前显示的订单号的“订单号”前会有一个复选标记。 您只需单击其名称即可将视图切换到另一个显示缓冲区。

['multiple launch part':]

If you have an ant launch configuration which does what you want, you can always transform it into a java launcher calling ant.

Main Class: org.apache.tools.ant.Main

-Dant.home=${resource_loc:/myPath/apache_ant} 
-f ${resource_loc:/myProject/config/myFile-ant.xml}

You can then launch this ant session as a regular java application, with all eclipse debugging facilities at your disposal.

Add to your classpath in the User Entries section (before your project and default path):

  • ant.jar
  • ant-launcher.jar

[Multiple console part]

May be a possible solution would be to make sure your ant launcher actually launches the different application in their own JVM process (one javaw.exe for each application)

That way, you could use the ability of the native eclipse console to switch between different process.

The Console view clearly separates output from each distinct "process" and keeps them in several "buffers". The Console has a built-in "switch" feature that will automatically switch the view to display the buffer of the last process that performed output, however you can easily switch the display to any "process buffer" you want to look at.

To switch the Console "buffer" display, just click on the black "Down arrow" next to the 4th toolbar button from the right in the Console View's title bar (the button
that resembles a computer screen):
this will show a pop-down menu listing the "names" of all active process buffers, preceded by an "order number".
The one currently displayed will have a check-mark before its "order number". You can switch the view to another display buffer simply by clicking on its name.

↙厌世 2024-07-15 17:58:11

The question and selected answer here are both 6 years old.

Eclipse Launch Groups provides UI to run multiple launch configs. Launch Groups is apparently part of CDT but can be installed separately without CDT by installing "C/C++ Remote Launch" (org.eclipse.cdt.launch.remote).

纵情客 2024-07-15 17:58:11

实际上,在 Eclipse 站点上打开了一张请求此完全相同功能的票证。 其中一位贡献者提出了一个插件,它允许对更多启动配置(可能是不同类型的)进行分组,并通过单击鼠标启动所有配置。

虽然插件功能有限,但效果很好。 包含源代码,因此您可以根据需要进行更改。 您必须在 Eclipse 中将其作为 PDE 项目打开,并将其导出为 JAR,然后将该 JAR 文件放入 Eclipse 的插件文件夹中。 有点麻烦,但你只需要执行一次。 之后重新启动 Eclipse 并在启动配置对话框中查找“Basic Workflow”。

插件源代码可在此处获取: https://bugs.eclipse.org/bugs /show_bug.cgi?id=39900#attach_177951

There's actually a ticket opened at Eclipse site which requests this very same functionality. One of the contributors there proposed a plugin which allows grouping more launch configurations (possibly of different types) and start all of them with one mouse click.

Although the plugin functionality is limited, it does a great job. Source code is included so you can make changes as necessary. You will have to open it as a PDE project in your Eclipse and export it as a JAR, then place the JAR file in your Eclipse' plugins folder. A bit cumbersome but you do this only one time. After that restart your Eclipse and look for "Basic Workflow" in your launch configurations dialog.

Plugin source is available here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=39900#attach_177951

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文