简体   繁体   English

跨平台开发建议

[英]Cross Platform Development Suggestions

Im working on a project in java that will eventually run on linux and windows machines and maybe mac.我正在从事 java 中的一个项目,该项目最终将在 linux 和 windows 机器上运行,也许还有 mac。 My program installs/configures vnc server so I'm looking for suggestions on how I should implement this part of the project.我的程序安装/配置 vnc 服务器,所以我正在寻找有关如何实施这部分项目的建议。 Should I just have a modular design or would it be possible to create a platform independent architecture for this problem?我应该只是有一个模块化设计,还是可以为这个问题创建一个独立于平台的架构?

I think that if VNC configuration is different on different platform you should just create interface and hierarchy of classes that implement it, ie我认为,如果不同平台上的 VNC 配置不同,您应该只创建实现它的类的接口和层次结构,即

public interface VncConfigurator {
    public void configure(Configuration cofiguration) throws ConfigurationException;
}

public class WindowsVncConfigurator implements VncConfgurator {
    public void configure(Configuration cofiguration) throws ConfigurationException {}
}

public class LinuxVncConfigurator implements VncConfgurator {
    public void configure(Configuration cofiguration) throws ConfigurationException {}
}

etc, etc.等等等等

You can also create abstract configurator or cofigurator utils where the common logic will be implemented.您还可以创建抽象配置器或配置器实用程序,用于实现通用逻辑。

Now create factory that instantiates "right" implementation of configurator according to the platform.现在创建工厂,根据平台实例化配置器的“正确”实现。 And you are done.你完成了。

I believe that on Windows you will need some additional libraries, eg those that provide access to registry.我相信在 Windows 上,您将需要一些额外的库,例如那些提供注册表访问权限的库。 But if you need this first check the following link: http://alexradzin.blogspot.com/2011/01/access-windows-registry-with-pure-java.html但是,如果您需要首先检查以下链接: http://alexradzin.blogspot.com/2011/01/access-windows-registry-with-pure-java.html

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

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