写了一个java程序,程序启动时会读取和jar包统计目录的myapp.conf文件在linux中通过java-jarmyapp.jar的方式可以正常启动程序但是在把命令加入到rc.local后却无法启动,查看日志发现是不能读取到myapp.conf文件rc.local文件#!/bin/sh#Thisscriptwillbeexecuted*after*alltheotherinitscripts.#Youcanputyourowninitializationstuffinhereifyoudon't#wanttodothefullSysVstyleinitstuff.touch/var/lock/subsys/localexportJAVA_HOME=/usr/java/jdk1.7.0_71exportCLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jarexportPATH=$PATH:$JAVA_HOME/binjava-jar/opt/agent/myapp.jar>/opt/agent/myapp.out2>&1&是不是rc.local在执行java程序时会认为脚本所在目录为执行目录?java读取文件的方法publicstaticStringGetFile(StringfileName){StringstrContent="";try{StringstrEncoder=GetEncoder(fileName);BufferedReaderbiFile=newBufferedReader(newInputStreamReader(newFileInputStream(fileName),strEncoder));StringstrSingleLine;while((strSingleLine=biFile.readLine())!=null){strContent+=strSingleLine;strContent+="\n";}biFile.close();}catch(Exceptione){System.out.println(e.getLocalizedMessage());}finally{returnstrContent;}}各位帮忙看看应该怎么办?
忽然笑
相关分类