Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to enable the (JAR) file to access an external folder that is needed in the application?
    primarykey
    data
    text
    <p>Please, My Java application is suppose to access an external folder which contains some other files. It was working perfectly under the Netbeans IDE but not when i run the (jar) file alone. I thought including the external desired folder within the same path as the jar file will solve the issue but sadly it gave me the same results. </p> <p>Any ideas or suggestions are greatly appreciated! </p> <p>Thanks in Advance!</p> <p>P.S: I am using the following command: java -jar MyJarFile.jar </p> <p>[Added]</p> <p><strong>My File structure:</strong> </p> <p>In the main folder of the project i have the following: </p> <p><strong>build<br> build.xml<br> Data: Inside this folder is my log file (log.dat).<br> dist: Inside this folder is my (.Jar) file.<br> manifest.mf<br> nbproject<br> README<br> src</strong> </p> <p>The code to access the file is written as follows: </p> <p><strong>File logs_File = new File("Data" + File.separator + "log.dat");</strong></p> <p>Again within my NB it is working this way but not when i lunch the .Jar file.</p> <p><strong>[Updated]</strong></p> <p>Up to know, i have been trying the following: </p> <p>The file to access the file looks as follows now: File logs_File = new File(this.getClass().getResource("/Data/log.dat").toString());</p> <p>Then i copied the Data folder to following directories:<br> <strong>src<br> build/classes/<br> dist</strong><br> <strong>and in the main directory</strong> </p> <p>And still it is not seeing the file. Though this time not even netbeans is able to locate the file.</p> <p>Thanks in advance for your help</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload