通过双击启动Java程序 [英] Launching a Java program via double click

查看:108
本文介绍了通过双击启动Java程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在开发的Java程序.我想把它展示给我的女友,她对如何使用Java毫无头绪,并且使她很容易做到这一点.我知道第一步是从命令行将其编译为.class,但此后我一无所知.

I have a Java program that I have been working on. I would like to show it to my girlfriend, who would have no clue as to how to work with Java, and make it easy for her to do so. I understand the first step is to compile it to .class 's from the command line, but after that I am clueless.

我想了解如何在Windows和Mac OS上同时执行这两个操作(我和朋友一起在Mac上,但我的学校使用Windows计算机).

I would be interested in finding out how to do this both for Windows and Mac OS (I am on a Mac, along with my girlfriend, but my school uses Windows computers).

我去过Oracle并看过他们的演示,他们以.jnlp下载,这是朝正确方向迈出的一步吗?

I have been on Oracle and seen their demos, they download as .jnlp, is that a step in the right direction?

特别是,我正在寻找一种简单下载并启动的,不涉及终端的文件"(也许是带有命令行的文件?).

And specifically, I am looking for a "file" of some sort that is simply downloaded and launched, no terminal involved (maybe a file with a command line within?).

推荐答案

通过双击启动Java程序
..seen ..演示,他们以.jnlp下载,这是朝正确方向迈出的一步吗?

Launching a Java program via double click
..seen .. demos, they download as .jnlp, is that a step in the right direction?

标题和引号通常表示启动Java桌面应用程序的两种不同方式.

The title and that quote typically represent two different ways to launch Java desktop apps.

  1. 以.jnlp下载" 这是豪华"版本,称为 Java Web Start .对于开发人员(您)而言,这有点棘手,但对用户(您的朋友)而言则非常容易.
  2. 通过双击启动Java程序" 通常与可执行Jar关联. (尽管JWS还支持双击"-但具有菜单和快捷方式.)
  1. "download as .jnlp" That is the 'deluxe' version, known as Java Web Start. It is a little trickier for the developer (you) but very easy for the user (your friend).
  2. "Launching a Java program via double click" is more commonly associated with an executable Jar. (Although JWS also supports the 'double click' - but with menus and shortcuts.)

这两种策略都可以在OS X,Windows或* nix上使用,但第一种策略具有JRE版本控制(确保最终用户具有JRE,并且足以运行代码),并借助脚本以及许多其他钟声和口哨声."

Either strategy will work on OS X, Windows or *nix, but the first has JRE versioning (making sure the end user has a JRE, and it is recent enough to run the code) assisted by scripts, and many other 'bells and whistles'.

  • JWS应用程序.通常是从用户计算机可以访问的网页或服务器上部署的,因此您的朋友浏览"到您发送给她的链接到在这里下载".
    • 当她到达您的网页时,deployJava.js将检查她的PC是否具有合适的最低Java版本来运行该应用程序.如果没有,她将指导您完成该过程.
    • 当确认JRE时(对于使用JRE更高版本的人来说是不可见的),脚本将在网页中写入一个链接,默认情况下该链接是一个按钮.
    • JWS apps. typically deployed from a web page or server accessible to the user machine, so your friend 'surfs on over' to the link you sent her to 'Download here'.
      • The moment she arrives at your web page, the deployJava.js will check her PC has a suitable minimum version of Java to run the app. If not, she will be guided through a process to get it.
      • When the JRE is confirmed (which happens invisibly for those with a later JRE) the script writes a link in the web page that by default is a button.

      另一种较小的替代方法是.

      Another lesser alternative is an executable-jar.

      它在Jar中使用一个manifest.mf来指定主类.

      It uses a manifest.mf in the Jar that specifies the main class.

      虽然对最终用户的使用体验较小,但对开发人员来说也更简单-在有限的分发范围内,这种权衡可能会派上用场.

      While being a lesser experience for the end user, it is also simpler for the developer - a trade off that might come in handy for limited distribution.

      • 需要安装合适的JRE版本.
      • 用户可以从任何来源(USB,蓝牙,网站等)获取Jar,并将其保存在方便的机器上的任何位置.
      • 要启动它,用户双击 Jar.
      • Requires a suitable version JRE installed.
      • The user obtains the Jar from whatever source (USB, Bluetooth, web site etc.) and saves it anywhere on their machine that is convenient.
      • To launch it, the user double clicks the Jar.

      这篇关于通过双击启动Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆