所有平台上的java [英] java on all platforms

查看:120
本文介绍了所有平台上的java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您想在java for windows,mac和linux中编写桌面应用程序代码,那么所有代码​​的代码是否相同?

if you wanna code a desktop application in java for windows, mac and linux, will the code be the same for all of them?

你只需更改GUI使Windows应用程序更像Windows等等?

and you just change the GUI so that the Windows application will be more Windows-like and so on?

如何在不深入细节的情况下工作?

how does it work without digging into details?

推荐答案

Java的一个卖点是一次编写,随处运行(几乎)。

One of Java's selling points is that is is "Write Once, Run Anywhere" (pretty much).

编译的字节码由Java虚拟机(JVM)执行。 JVM特定于其运行的平台,但任何具有JVM的平台都可以执行相同的字节码。代码不必重新编译。

The compiled bytecode is executed by the Java Virtual Machine (JVM). The JVM is specific to the platform that it runs on but the same bytecode can be executed by any platform that has a JVM. The code does not have to be recompiled.

Swing是Java的跨平台GUI工具包。您可以对其进行配置,使其具有在不同平台上看起来相同的GUI(它们在任何平台上看起来都不是原生的),或者您可以告诉它使用最适合它的平台的外观正在执行。因此,如果您在Windows上运行它将看起来像一个Windows应用程序,如果您在OS X上运行它将看起来像一个原生的Mac应用程序。

Swing is Java's cross-platform GUI toolkit. You can configure it so that it has a GUI that looks the same across different platforms (it won't look native on any of them), or you can tell it to use the most appropriate look-and-feel for the platform that it is executing on. So if you run on Windows it will look like a Windows app, if you run on OS X it will look like a native Mac app.

这篇关于所有平台上的java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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