简体   繁体   English

为Windows和Mac制作Java应用程序

[英]Making Java Application for Windows & Mac

Just started coding in Java, I have a lot of experience in VB. 刚开始用Java编写代码,我在VB中有很多经验。 I really really would appreciate if someone can point me towards the right direction ! 如果有人能指出我正确的方向,我真的很感激!

I am developing a simple application which should be able to run in Windows (xp, Vista, 7.. 32 & 64 bit) and on mac too. 我正在开发一个简单的应用程序,它应该能够在Windows(xp,Vista,7 .. 32和64位)和Mac上运行。

Here are a few question I have :- 以下是我的一些问题: -

  1. Do I need to make multiple versions for each windows(xp, Vista, 7.. 32 & 64 bit ) & Mac? 我是否需要为每个窗口(xp,Vista,7 .. 32和64位)和Mac制作多个版本?
  2. How do we make changes to registry any inbuilt in java ? 我们如何对java内置的注册表进行更改?
  3. Make the application auto Updating 使应用程序自动更新

Any help resource links is highly appreciated so that I can hopefully do the same for someone else someday ! 任何帮助资源链接都非常受欢迎,所以我希望有一天能为其他人做同样的事情!

  1. No. Java has the principle "compile once, run everywhere." 没有.Java的原则是“编译一次,到处运行”。 - meaning, everywhere where you have a suitable JRE. - 意思是,在任何地方你都有合适的JRE。

    This holds as long as your application doesn't need to do platform-specific things (and even then it often is possible to either do these things with a platform switch in Java, or deliver a native library for each platform). 只要您的应用程序不需要执行特定于平台的事情(即使这样,通常可以使用Java中的平台交换机执行这些操作,或者为每个平台提供本机库)也是如此。 If your application is "simple", you have a good chance that you don't. 如果您的申请“简单”,您很可能不会。

  2. If you only need registry changes for your own configuration, you should use java.util.prefs.* (Which may, depending on the system, store them in the registry). 如果您只需要为自己的配置更改注册表,则应使用java.util.prefs.* (这可能会根据系统将它们存储在注册表中)。 There is no build-in way to access the registry, since not each system has a registry (nor needs it). 没有内置的方法来访问注册表,因为并非每个系统都有一个注册表(也不需要它)。

  3. There is no build-in way to do this, but there are additional frameworks for this. 没有内置方法可以做到这一点,但还有其他框架。

  1. No, you don't. 不,你没有。 As long as your application is self-contained you'll be just fine. 只要您的应用程序是自包含的,您就可以了。
  2. That I'm not sure, I'd have to get back to you and edit it in. :-( 我不确定,我必须回复你并编辑它。:-(
  3. The Eclipse RCP framework makes auto-updating pretty darned easy. Eclipse RCP框架使自动更新非常容易。

Others have answered 1 and 3. I'll take a stab at 2. 其他人回答了1和3.我会在2点刺伤。

No built in way to editing the registry in Java probably because Java was designed to be portable while the registry is only specific to Windows. 没有内置的方法来编辑Java中的注册表可能是因为Java设计为可移植而注册表仅针对Windows。

But Windows does have a command line program "reg" that lets you modify the registry and you can use Java to call the command line. 但Windows确实有一个命令行程序“reg”,它允许您修改注册表,您可以使用Java来调用命令行。

1) May have to do different scripts to run the application? 1)可能必须执行不同的脚本来运行应用程序? I've seen a run.sh and run.bat in many cases for kickstarting 我在很多情况下都看过run.sh和run.bat用于kickstarting

2) No Idea, but I believe that if you want to be cross-platform you should avoid it (no registry on linux/osx). 2)没有想法,但我相信,如果你想成为跨平台,你应该避免它(linux / osx上没有注册表)。 Using the registry not something java applications do a lot... 使用注册表不是java应用程序做了很多事情......

3) Don't know 3)不知道

I also believe that you are asking three distinct questions, an admin might help, but wouldn't it be better if you posted 3 questions instead of one? 我也相信你提出三个不同的问题,管理员可能会有所帮助,但如果你发布3个问题而不是一个问题会不会更好?

1 and 3 have been answered pretty comprehensively now 现在已经非常全面地回答了1和3

You can modify the registry with this http://sourceforge.net/projects/jregistrykey/ library but it's fairly complex for a beginner and if you are looking at a cross platform application then there is no point making these changes, try keep your settings local to the Java application if possible. 您可以使用此http://sourceforge.net/projects/jregistrykey/库修改注册表,但对于初学者来说它相当复杂,如果您正在查看跨平台应用程序,则无需进行这些更改,请尝试保留您的设置尽可能在Java应用程序本地。

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

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