jar策略文件 [英] jar policy file

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

问题描述

我将我的java应用程序打包到一个jar文件中,但它只打包了类文件。
当我从命令行运行java程序时,通常这就是我要做的事情:

I'm packaging my java application into a jar file but it only packages the class files. When I run the java program from the command line, usually this is what I have to do:

java -Djava.security.policy =.. \ java.policy服务器

java -Djava.security.policy="..\java.policy" Server

我的问题是:有没有办法打包jar文件并包含这个策略文件?例如,当用户想要运行jar文件时,他/她需要做的就是键入:

My question is: is there a way to package a jar file and include this policy file? For instance, When the user wants to run the jar file, all he/she needs to do is type:

java -jar Server

java -jar Server

推荐答案

您可以将策略打包到jar文件中并编写一些内务代码,以便从给定的策略文件创建安全管理器。类加载器完成了艰苦的工作。 此处是一个样本。

You can package the policy into the jar file and write some housekeeping code to create a security manager from the given policy file. The classloader does the hard work. Here is a sample.

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

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