I am trying to load a text file as InputStream, but the txt file is never picked up and the input stream value is always null . I don't know why this is happening and I would like to request assistance.
nohup java -jar crawler-jar-2014.11.0-SNAPSHOT.jar -classpath /home/nbsxlwa/crawler/resources/common-conf:/home/nbsxlwa/crawler/resources/dotcom-conf:./plugins/*:./lib/* &
The txt file is located in /home/nbsxlwa/crawler/resources/dotcom-conf
directory. I can confirm that the file does exist, so I don't know why the file is not being picked up. The setup is given below:
`System.getEnvironment("java.class.path")
returns the following value crawler-jar-2014.11.0-SNAPSHOT.jar
The code blocks are trying to create an input stream out of text.
String fileRules = conf.get(URLFILTER_REGEX_FILE); System.out.println("file rules = " + fileRules); // Pass the file as a resource in classpath. // return conf.getConfResourceAsReader(fileRules); // Pass the file as a resource in classpath. InputStream is = RegexURLFilter.class.getResourceAsStream("/" + fileRules); System.out.println("Inputstream is = " + is); System.out.println(ClassLoader.getSystemResourceAsStream(fileRules));
The output to the above snippet is
file rules = regex-urlfilter.txt
Inputstream is = null
null
Class-Path: resources/common-conf resources/dotcom-conf resources/olb-conf lib/gora-cassandra-0.3.jar ** OTHER JARS**
Note the java
man page entry for -jar
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
So your other classpath entries are ignored. You'll have to use the plain old java
command, specifying a class with a main method and including your .jar
in the classpath.
The relative paths you've specified in the MANIFEST are relative to the JAR itself or are complete URLs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.