我已经创建了一个shell脚本来在Ubuntu中运行我的项目。在那里,我必须提供属性文件路径以及Java命令。
我正在使用此命令执行此操作,但它无法正常运行该文件,并且正在尝试使用NullPointerException
。
/ usr / lib / jvm / java-7-openjdk-i386 / bin / java“-cp $ CLASSPATH -Doligosoft.POSconfig.file = /家庭/ mlpc04 / Paritosh / POS_3.0 /资源/ posconfig.properties com.floreantpos.main.Main
在Classpath中我已经正确地给出了这个文件所在的位置,但是不知道出了什么问题,请告诉我我正在使用的命令是正确的,或者问题是别的。
编辑
private static void loadPosConfig() {
String filename = System.getProperty( "oligosoft.POSConfig.file" );
posConfig = new Properties(); System.out.println(filename);
File file = new File(filename);
System.out.println( file.getAbsolutePath());
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream( file ); posConfig.load(inputStream);
} catch ( Exception e) { logger.error( "Not able to load configuration" , e ); }
我在我的应用程序的这个方法中使用该文件,但我试图通过我的脚本提供此文件。
答案 0 :(得分:1)
您在使用-Doligosoft.POSconfig.file=...
代替-Doligosoft.POSConfig.file=...