अनुसंधान के एक बहुत कर रही है और यह भी अनुसंधान के बाद मेरे कोड में यह लागू करने के बाद यह सवाल पूछ रहा हूँ, लेकिन मैं वास्तव में FileNotFoundException.What यहाँ कर रहा हूँ के साथ समाप्त हो गया मैं अपने जावा में hardcoding से बचना चाहते हैं है कोड इसलिए एक गुण फ़ाइल को Constants.properties के नाम से बना रहा हूं और इसे अपने जावा कोड में कॉल कर रहा हूं। लेकिन यह कहता है कि यह फ़ाइल नहीं ढूंढ रहा है। मेरी गुण फ़ाइल प्रोजेक्ट के src फ़ोल्डर में है। नीचे कोड स्निपेट है। कोई सुझाव?FileNotFoundException जब जावा गुण का उपयोग कर फ़ाइल
गुण फ़ाइल:
executable.run = C:\\server\\lrd.exe
incoming.file = C:\\file\\test.ic
executable.params1 = -z
executable.params2 = -a[+]
log.file = C:\\TESTFile\\test.txt
जावा कोड: यह जो है गुण विवरण दाखिल वर्ग फ़ाइल है।
public class PropInfo {
static private PropInfo _instance = null;
public String executable = null;
public String filein = null;
public String params1 = null;
public String params2 = null;
public String log = null;
protected PropInfo(){
try{
InputStream file = new FileInputStream(new File("Constants.properties"));
Properties props = new Properties();
props.load(file);
executable = props.getProperty("executable.run");
filein = props.getProperty("incomin.file");
params1 = props.getProperty("executable.params1");
params2 = props.getProperty("executable.params2");
log = props.getProperty("log.file");
}
catch(Exception e){
System.out.println("error" + e);
}
}
static public PropInfo instance(){
if(_instance == null){
_instance = new PropInfo();
}
return _instance;
}
}
मुख्य वर्ग:
errorjava.io.FileNotFoundException: Constants.properties (The system cannot find the
file specified)
java.io.IOException: Cannot run program "null": CreateProcess error=2, The system
cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at com.emc.clp.license.StartTest.main(StartTest.java:44)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the
file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:288)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
... 4 more
जो लाइन में अपवाद हो रहा है? –
@JavaDevil: अपवाद प्रक्रिया जनसंपर्क = rt.exec (connString) पर उत्पन्न की है, – user2821894
कृपया अपवाद स्टैक ट्रेस पोस्ट करें। –