2013年11月18日星期一

Distribution of executable jar when an error path not found problem

1 Statement ~ eclipse in normal operation procedures

2. loading configuration files ROAD KING code
rootFile=this.getClass().getResource("").toString().substring(6);
控制台输出效果rootFile:E:/workspace/BroadcastControl/bin/zd/main/

3. configuration file directory :
folder src --- package name zz.main profile ConParam.properties

4. publish jar execution Screenshot



seek advice
------ Solution ---------------------------------- ----------
yes ah ~ ~ I do not know it then I put extra characters all deleted or not   
    
direct reference to the jar package path seemingly nowhere.
But you can load the stream way to get the configuration information

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


jar package structure :

------ For reference only ----- ----------------------------------
D: \ before how much le:

------ For reference only ---------------------------------- -----
yes ah ~ ~ I do not know it then I put extra characters all deleted or not

------ For reference only ----- ----------------------------------
yes ah I do not know it ~ ~ then I the extra characters all deleted or not   
    
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify
------ For reference only ------------------------- --------------
yes ah ~ ~ I do not know it then I put extra characters all deleted or not     
              
direct reference to the jar package path seemingly nowhere.   
But you can load the stream way to get the configuration information   
  

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
  
  
jar package structure :   
    
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify
------ For reference only ------------------------- --------------
yes ah ~ ~ I do not know it then I put extra characters all deleted or not       
                      
direct reference to the jar package path seemingly nowhere.     
But you can load the stream way to get the configuration information     
    

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    
    
jar package structure :     
              
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify  


Yes, ah I do not know it ~ ~ Then I deleted all the extra characters or not       
                      
direct reference to the jar package path seemingly nowhere.     
But you can load the stream way to get the configuration information     
    

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    
    
jar package structure :     
              
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify  
you take me into your document that ttt.txt configuration files can not it ?
you load the configuration file is not just to get the data ? Or stream information ?
read as xml or other forms ?
is streaming there, what else can not reproduce it ?
------ For reference only -------------------------------------- -
Yes, ah I do not know it ~ ~ then I deleted all the extra characters or not         
                              
direct reference to the jar package path seemingly nowhere.       
But you can load the stream way to get the configuration information       
      

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
      
      
jar package structure :       
                      
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify          
  
  
  Yes, ah I do not know it ~ ~ Then I deleted all the extra characters or not         
                              
direct reference to the jar package path seemingly nowhere.       
But you can load the stream way to get the configuration information       
      

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
      
      
jar package structure :       
                      
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify          
you take me into your document that ttt.txt configuration files can not it ?   
you load the configuration file is not just to get the data ? Or stream information ?   
read as xml or other forms ?   
is streaming there, what else can not reproduce it ?  
is capable of read operations , but when I want to read and modify the operation
this.getClass (). getResourceAsStream (
"/ lib / ttt.txt"); This returns the input stream I want an output stream object modification to the configuration . looked at the API to obtain output objects seemingly no way
- ---- For reference only ---------------------------------------
is ah I do not know it ~ ~ then I deleted all the extra characters or not           
                                      
direct reference to the jar package path seemingly nowhere.         
But you can load the stream way to get the configuration information         
        

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
        
        
jar package structure :         
                              
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify                
    
    
    Yes, ah I do not know it ~ ~ Then I deleted all the extra characters or not           
                                      
direct reference to the jar package path seemingly nowhere.         
But you can load the stream way to get the configuration information         
        

InputStream is = this.getClass().getResourceAsStream(
"/lib/ttt.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = "";
try {
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
        
        
jar package structure :         
                              
I tried it possible to modify the configuration , but how ? ? My project is the need to read the configuration file and modify                
you take me into your document that ttt.txt configuration files can not it ?     
you load the configuration file is not just to get the data ? Or stream information ?     
read as xml or other forms ?     
is streaming there, what else can not reproduce it ?          
is capable of read operations , but when I want to read and modify the operation   
this.getClass (). getResourceAsStream (   
"/ lib / ttt.txt"); This returns the input stream I want an output stream object modification to the configuration . looked under the API seemingly no way to obtain output objects  
http://www.blogjava.net/monsoongale/articles/305342.html
yourself. I have not encountered such a demand . . .

没有评论:

发表评论