Java 桌面应用程序的局限性?

发布于 2024-07-24 10:39:36 字数 164 浏览 11 评论 0原文

我有 C/C++ 背景,现在做很多 C# 的工作。

最近,自从使用 Android SDK 以来,我对用 Java 做一些项目产生了兴趣。

我知道 Java 应用程序在沙箱中运行,这会限制它们对系统的访问。

在桌面/服务器应用程序环境中哪些内容受到限制?

I come from a C/C++ background and now do a lot of C# stuff.

Lately I have become interested in doing some projects in Java since playing around with the Android SDK.

I know that Java apps run in a sandbox that can limit their access to the system.

In a desktop/server application environment what kind of things are restricted?

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

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

发布评论

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

评论(4

寒江雪… 2024-07-31 10:39:36

Java 应用程序位于沙箱中,就像 .NET 应用程序位于沙箱中一样。 它们都在各自的虚拟机上运行,​​并且在可以执行的操作方面确实有一些限制,但在大多数情况下,它们对系统具有大量访问权限,包括通过某些调用访问本机代码。

您可能正在考虑 Java 小程序,它运行在浏览器内,通常位于安全沙箱中,以防止访问本地文件等系统资源。 (可以通过专门向某些小程序授予对系统的访问权限来规避此限制。)

这是关于 来自 小程序的安全限制 Java 教程,其中包括对小程序的限制列表。

Java applications are much in a sandbox as .NET applications are in a sandbox. They both run on their respective virtual machines, and do have some limitations as to what they can do, but for the most part, they have a good deal of access to the system, including access to native code through certain calls.

You may be thinking about Java applets, which run inside a browser, and generally will be in a security sandbox that prevents access to the system resources such as local files. (This restriction can be circumvented by specifically granting access to the system to certain applets.)

Here's a section on Security Restrictions for applets from The Java Tutorials, which includes a list of restrictions placed on applets.

九八野马 2024-07-31 10:39:36

通常,桌面和服务器应用程序在禁用安全性的情况下运行。 但是,Java 和 JVM 仍然具有强大的类型系统,因此您无法转换为未创建对象的类型,无法访问已释放的内存,也无法超出缓冲区末尾。

Typically desktop and server application run with security disabled. However, Java and the JVM still have a robust type system, so you can't for instance cast to types that an object was not created with, cannot access freed memory and can't run off the end of buffers.

姜生凉生 2024-07-31 10:39:36

对于普通的桌面和服务器应用程序,这些限制与沙箱概念无关(尽管您可以使用它对用户提交的代码等应用非常细粒度的限制),而是与 Java 的平台无关性有关。 基本上,特定于操作系统的内容和硬件访问通常无法在纯 JAVA 中完成,除非 API 库专门解决。

示例有:

  • Windows 注册表
  • Windows 系统托盘
  • 蓝牙
  • WLAN 配置

For normal desktop and server apps, the limitations are not related to the sandbox concept (though you could use it to apply very fine-grained restrictions to e.g. user-submitted code) but to the platform-independant nature of Java. Basically, OS-specific stuff and hardware access usually can't be done in pure JAVA unless specifically adressed by the API library.

Examples are:

  • Windows registry
  • Windows system tray
  • Bluetooth
  • WLAN configuration
灰色世界里的红玫瑰 2024-07-31 10:39:36

我认为您可能会看到的主要限制是,如果您需要的话,轻松使用本机系统 API 的能力,例如,如果您需要使用 user32 或 kernel32 API java 我认为这是可能的,但是这不是一件容易的事,但是在 C# 中这是相当容易的事情。

此外,如果您有一些遗留的 C/C++ dll,您仍然可以在 C# 应用程序中使用它们,而在 java 中仍然很难做到,特别是在最坏的情况下,当您的本机代码 api 必须使用指针时,您可以在C# 应用程序传递指针并在堆栈上分配固定内存...等等,

但如上所述 一般来说,C# 具有相同的局限性,特别是如果您的目标是独立于平台。

I think the main limitation you might see, is the ability to easily use the native system API's if you needed, for example if you needed to use a user32 or kernel32 API from java I think it is possible, however it is not an easy task to do, however in C# it is fairly easy thing to do.

Also if you have some legacy C/C++ dll's you can still use them in a C# application, while in java is still hard to do especially that in the worst case when your native code api has to use pointers, you can use unsafe mode in C# application to pass pointers and allocate fixed memory on stack ... etc.

but as mentioned above Java & C# in general are very much have the same limitations especially if you are targetting being platfrom independent.

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