简体   繁体   English

如何使用 Java 应用程序而不是桌面?

[英]How Can I Use a Java Application Instead of Desktop?

I want to make a Java Application that will start automatically when I start the computer and will run instead of the desktop, so the desktop-terminal etc will be unreachable for users.我想制作一个 Java 应用程序,它会在我启动计算机时自动启动并运行而不是桌面,因此用户无法访问桌面终端等。 The users must use nothing but the application and when they close the application, the computer also must be turned off automatically.用户只能使用应用程序,当他们关闭应用程序时,计算机也必须自动关闭。 How can I do such a thing for a simple Java Application (jar)?我怎样才能为一个简单的 Java 应用程序(jar)做这样的事情?

Shortly, for ubuntu you have to:很快,对于 ubuntu,您必须:

  • Remove desktop environment, just look around for some guides, it depends by which desktop you have (GNOME, XFCE, KDE, etc).删除桌面环境,只需四处寻找一些指南,这取决于您拥有的桌面(GNOME、XFCE、KDE 等)。 https://askubuntu.com/a/147870 https://askubuntu.com/a/147870

  • Add a script in /etc/rc.d and link it in rcS.d https://unix.stackexchange.com/a/83752 .在 /etc/rc.d 中添加一个脚本并将其链接到 rcS.d https://unix.stackexchange.com/a/83752中。
    The script have to run your application, wait for end and shutdown, an example could be:该脚本必须运行您的应用程序,等待结束并关闭,例如:

     #./bin/bash nohup java -jar MyApp.jar & wait /sbin/shutdown -r now

Try this in a virtual machine that you can reach in SSH or in some other ways, after you removed desktop environment, you cannot open a terminal.在 SSH 可以访问的虚拟机中尝试此操作或通过其他方式,删除桌面环境后,无法打开终端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM