Note that there are some explanatory texts on larger screens.

plurals
  1. POOutput file generated in Eclipse but not in jar file
    text
    copied!<p>I have a simple parsing program that takes a few files and combines them. It then generates a few output files to the working directory. When I run this program in eclipse it generates all the required output files. However, when I run it using a jar generated in eclipse it only creates two of the three output files. It makes me think something is wrong in how the jar file is generated but can't seem to find any answers to this. </p> <p>I've tried updating some of the java, it was written using java 5 I believe. I just changed the Vectors to ArrayLists and the FileOutputStream to FileWriter. </p> <p>I had to download javax.mail to get the required libraries and added those jar files to the java6 library I was using in Eclipse. I've tried deleting the classes and generating new classes. I tried to check the permissions on the jar file to make sure that I had access with it. I guess I am just not sure where to start. </p> <p>I've also tried packing this as a jar file and not as a runnable jar file because it gave me more options on what to include. However, I could not run this type of jar file even though it was an executable. I've recreated the jar file numerous times without any luck. </p> <p>There were quite a few problems people had with UTF-8 not displaying properly in a jar file but being fine in eclipse. However their jar files were generating the text files where as mine just does not generate one. </p> <p>Update: Interestingly if I move the block of code to its own class and run it as a separate jar it will work. So the solution for now is to have two jar files.</p> <p>This is the code for the ungenerated file:</p> <pre><code>private static void parseCRNOnly() { try { //file to write to File new_file = new File("CRNOnlyClean.txt"); FileWriter out = new FileWriter(new_file); //file to read from File file = new File("CRNOnly.txt"); FileReader reader = new FileReader(file); BufferedReader buf = new BufferedReader(reader); try{ String str; String temp = "\r"; String nl = "\r\n"; String tab = "\t"; str = buf.readLine(); while (str != null &amp;&amp; !str.isEmpty()) { StringTokenizer tokenizer = new StringTokenizer(str," \t"); int column = 0; while(tokenizer.hasMoreTokens()) { column++; temp = tokenizer.nextToken(); if(column == 8){ break; } out.write(temp); out.write(tab); } out.write(nl); str = buf.readLine(); } out.close(); } catch(IOException e0){ System.out.println("Error Reading From CRNOnly.txt"); JOptionPane.showMessageDialog(null, "Error Reading From CRNOnly.txt"); } } catch(FileNotFoundException e1){ System.out.println("File CRNOnly.txt Not Found"); JOptionPane.showMessageDialog(null, "File CRNOnly.txt Not Found"); } catch (IOException e) { System.out.println("Error Reading from FileWriter"); JOptionPane.showMessageDialog(null, "Error Reading from FileWriter"); } </code></pre>
 

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