Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0

    Runs fine in ide crashes otherwise


    I have a java program that seems to work okay when I'm debugging it or running it from the Eclipse IDE. But when I export it into a jar file and run it through a jnlp it hangs at a certain step.

    One possible cause of the problem might be a step when I'm converting a file into a text file.

    Code:
    private File INPUT;
    	private JTextArea innerTextArea;
    
    	    protected boolean rangeArgsProvided = false;
        
         Converter(File INPUT, JTextArea innerTextArea) { 
             //initialize 
        	 this.INPUT = INPUT;
             this.innerTextArea = innerTextArea;
    
         }
        
    @Override
    public File doInBackground() {//replaces doWork
      	File convertedBAM = new File("convertedFile.txt");
    	int convertstepcounter=0, convertstepcounter2=0;

    I'm not specifying any specific location to get or put the file convertedFile.txt in. Its just a variable that will take the converted information and then pass on in a later step and not be used anymore. Is this the likely problem thats causing the crash or is it probably due to something else?



    PS the jar runs from the Local Settings/Temp Folder in windows. Someone else made it that way.
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Have you tried using an absolute file path?
  4. #3
  5. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    What is the full text of the error message? That will tell you what the problem is and where it happened.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by NormR
    What is the full text of the error message? That will tell you what the problem is and where it happened.
    There is no error message. The java program just gets to the step where it would begin converting a binary to txt file and hangs there when run from a jar. If it was being run through the ide it would sail through this step so ide debugging is useless.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    I tried editing the jnlp file so the program would run from its own folder on the desktop instead of the Temp folder but that didn't change anything.


    Originally Posted by bullet
    Have you tried using an absolute file path?

    How would you do that? I changed "convertedFile.txt" to "/jar/convertedFile.txt" in the file creation line above but it didn't work.


    Thanks
  10. #6
  11. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    hangs there when run from a jar.
    Do you know where the code is looping to cause it to "hang"? What are the values of the variables that cause it to loop? Try debugging the code by adding some println statements that print out the values of the variables that control the looping.
  12. #7
  13. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    I would suggest trying to run the jar file from the command line to see if it shows the error.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by NormR
    Do you know where the code is looping to cause it to "hang"? What are the values of the variables that cause it to loop? Try debugging the code by adding some println statements that print out the values of the variables that control the looping.
    Okay I plugged in some message statements and teh crashes appear to revolve around

    Code:
    File INPUT;
    input comes from a file the user browses using a file chooser from the interface. Basically the outline appears to be

    Code:
    selectedFile = jfileChooser.getSelectedFile();
    
    final FileConversion task = new FileConversion(selectedFile, txtArea);
    
    
    //Conversion Function
    
    FileConversion(File INPUT, JTextArea innerTextArea) { 
             //initialize 
        	 this.INPUT = INPUT;
             this.innerTextArea = innerTextArea;
    
         }
    
    @Override
    public File doInBackground() {
      	File convertedFile = new File("convertedFile.txt");
    	int convertstepcounter=0, convertstepcounter2=0;
    	
    publish( 1 );
    	IoUtil.assertFileIsReadable(INPUT);//crashes here
    publish( 2 );
        final SAMFileReader reader = new SAMFileReader(INPUT);//or here if above line is disabled. 
    publish ( 3 );
    

    So I guess the question is why would INPUT be okay when run from the IDE but not when run from a jar?
  16. #9
  17. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    teh crashes
    Can you explain what you mean by "crashes"? Normally I think of a crash being the program throwing an exception. An endless loop isn't a crash.
    I'd call it a bug.

    Where is the println statements in the code for debugging? I don't see any in the posted code.

    Where is the next println statement after the one that executed and printed.
    What statements are between the one that executed and printed and the one that did not print anything?

    why would INPUT be okay when run from the IDE but not when run from a jar?
    Because of different current directory values.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by NormR
    Can you explain what you mean by "crashes"? Normally I think of a crash being the program throwing an exception. An endless loop isn't a crash.
    I'd call it a bug.
    I dunno what it is, it just simply doesn't go on for some reason but I don't think its looping.

    Originally Posted by NormR
    Where is the println statements in the code for debugging? I don't see any in the posted code.
    I readded the publish statements to the code above. The program doesn't appear to do anything after printing out a '1' or if the line after is disabled, printing out a '2'. So I assume using INPUT is causing the problems somehow.

    Originally Posted by NormR

    Because of different current directory values.
    Input comes from a file the user selects using jfileChooser.getSelectedFile(); every time so I don't understand why it would matter what directory the program was running from.
  20. #11
  21. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    What packages is this code using?
    IoUtil.assertFileIsReadable(INPUT);//crashes here

    Do you have the source so you can debug what it is doing?
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by NormR
    What packages is this code using?
    IoUtil.assertFileIsReadable(INPUT);//crashes here

    Do you have the source so you can debug what it is doing?
    Its a library called picard. The source is buried in some jar so I was hoping I wouldn't have to monkey around with it since it seems clear to me that the problem has to do with INPUT rather than a mistake in the library but I'll get to it if it will help.
  24. #13
  25. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Originally Posted by Jarwulf
    Its a library called picard. The source is buried in some jar so I was hoping I wouldn't have to monkey around with it since it seems clear to me that the problem has to do with INPUT rather than a mistake in the library but I'll get to it if it will help.
    Are you running it from a browser or command line?
  26. #14
  27. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    INPUT is a reference to a File object. Is the File class from the Java SE java.io package?
    Why does the assertFileIsReadable() method hang (not return)? Does it hang with just one file or have you tried it with several files and it hangs with all of them?
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Originally Posted by bullet
    Are you running it from a browser or command line?

    Running the jar using Webstart (jnlp). Launch the jnlp and the jnlp launches the jar file.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo