设置系统属性

我正试图按照这个指令embedded运行门

它说:“系统属性gate.home应该设置为门安装目录”。 (http://gate.ac.uk/wiki/code-repository/)

我如何做到这一点?

另外,当我尝试运行EmbeddedAnnie的示例代码时,出现以下错误:(我不知道它是否相关)。

Initialising GATE... GATE home system property ("gate.home") not set. Attempting to guess... Using "C:\Program Files (x86)\GATE-6.0" as GATE Home. If this is not correct please set it manually using the -Dgate.home option in yo ur start-up script Using C:\Program Files (x86)\GATE-6.0 as GATE home Using C:\Program Files (x86)\GATE-6.0\plugins as installed plug-ins directory. Using C:\Program Files (x86)\GATE-6.0\gate.xml as site configuration file. Using C:\Users\UNST\gate.xml as user configuration file Using C:\Users\UNST\gate.session as user session file Exception in thread "main" java.lang.NoClassDefFoundError: gate/creole/gazetteer /AbstractGazetteer at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14 1) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:296) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:296) at gate.util.GateClassLoader.loadClass(GateClassLoader.java:63) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at gate.creole.CreoleAnnotationHandler.processAnnotationsForResource(Cre oleAnnotationHandler.java:193) at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotati onHandler.java:169) at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotati onHandler.java:173) at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotati onHandler.java:173) at gate.creole.CreoleAnnotationHandler.processAnnotations(CreoleAnnotati onHandler.java:157) at gate.creole.CreoleRegisterImpl.processFullCreoleXmlTree(CreoleRegiste rImpl.java:358) at gate.creole.CreoleRegisterImpl.parseDirectory(CreoleRegisterImpl.java :341) at gate.creole.CreoleRegisterImpl.registerDirectories(CreoleRegisterImpl .java:306) at gate.Gate.initCreoleRepositories(Gate.java:449) at gate.Gate.init(Gate.java:230) at StandAloneAnnie.main(StandAloneAnnie.java:69) Caused by: java.lang.ClassNotFoundException: gate.creole.gazetteer.AbstractGazet teer at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ... 27 more 

特德。

你可以通过几种方法做到这一点。

一个是当你运行你的应用程序,你可以传递一个标志。

java -Dgate.home="http://gate.ac.uk/wiki/code-repository" your_application

或者在需要此属性设置的代码片段之前以编程方式将其设置。 Java为System范围configuration保留一个Properties对象。

 Properties props = System.getProperties(); props.setProperty("gate.home", "http://gate.ac.uk/wiki/code-repository"); 
 System.setProperty("gate.home", "/some/directory"); 

有关更多信息,请参阅:

  • 系统属性教程 。
  • System.setProperty( String key , String value )类文档System.setProperty( String key , String value )

对于JBoss ,在standalone.xml中,放在后面。

 <extensions> </extensions> <system-properties> <property name="my.project.dir" value="/home/francesco" /> </system-properties> 

对于日食:

http://www.avajava.com/tutorials/lessons/how-do-i-set-system-properties.html?page=2

 System.setProperty("gate.home", "/some/directory"); 

之后,您可以稍后通过调用来检索其值

 String value = System.getProperty("gate.home"); 

您需要本地GATE安装的plugins目录的path。 因此,如果Gate安装在“/home/user/GATE_Developer_8.1”中,代码​​如下所示:

 System.setProperty("gate.home", "/home/user/GATE_Developer_8.1/plugins"); 

您不必从命令行设置gate.home。 你可以在你的应用程序中设置它,只要你在调用Gate.init()之前设置它。