Sandy

From Finninday
Jump to: navigation, search
  • fails when run from a jar like this:
2010-08-14 14:16:57.785: problem with dir file:/Users/rday/Desktop/sandy-processes/linearize/   
2010-08-14 14:16:57.786: Are the necessary files present with the correct permissions?

Had to add more diagnostics because when it works in eclipse, no messages are generated.

  • looks like this when it succeeds in eclipse:
2010-08-14 14:30:43.147: Testing dir (string): /Users/rday/Desktop/sandy-processes/linearize/
2010-08-14 14:30:43.149: Testing dir (file): /Users/rday/Desktop/sandy-processes/linearize
2010-08-14 14:30:43.160: Testing file (string): /Users/rday/Desktop/sandy-processes/linearize/run_proc_sandy.pl
2010-08-14 14:30:43.161: Testing file (file): /Users/rday/Desktop/sandy-processes/linearize/run_proc_sandy.pl
2010-08-14 14:30:43.161: Testing file (string): /Users/rday/Desktop/sandy-processes/linearize/linearize_gtsm_new.x
2010-08-14 14:30:43.162: Testing file (file): /Users/rday/Desktop/sandy-processes/linearize/linearize_gtsm_new.x
2010-08-14 14:30:43.163: Running process...Linearize on file /Users/rday/B018_CH0_int
  • looks like this when it fails from the jar
0-08-14 14:25:27.24: Testing resource (string): file:/Users/rday/Desktop/sandy-processes/linearize/
2010-08-14 14:25:27.25: Testing resource (file): file:/Users/rday/Desktop/sandy-processes/linearize
2010-08-14 14:25:27.26: problem with dir file:/Users/rday/Desktop/sandy-processes/linearize/   
2010-08-14 14:25:27.28: Are the necessary files present with the correct permissions?
  • root dir looks like this when run from eclipse
2010-08-14 14:29:49.692: Running withing eclipse, faking jar location.
2010-08-14 14:29:49.694: Location of jar: /Users/rday/Desktop/
  • root dir looks like this when run from a jar
2010-08-14 14:32:07.343: Location of jar: file:/Users/rday/Desktop/

Look at that, the rootPath variable has a "file:" prefix when run from a jar. Why would that be? rootPath is a string and I'm using it like this:

                                rootPath = "" + getClass().getResource("/");
				if (rootPath.contains("rday/Documents/workspace")){
					rootPath = "/Users/rday/Desktop/";
					addToLog("Running withing eclipse, faking jar location.");
				}
				addToLog("Location of jar: "+rootPath);

I suppose I need to strip off the "file:" prefix if it exists.

Still the error-checking code did not work as I expected, even after correcting the rootPath variable.

Here is the code:

File fTest = new File(sTest);
				SandyUI.addToLog("Testing "+sType+" (string): "+ sTest);
				//SandyUI.addToLog("Testing "+sType+" (file): " + fTest.getPath());
				if (sType.equals("dir")) {
					SandyUI.addToLog("testing existence of directory...");
					if (fTest.isDirectory()) {
						SandyUI.addToLog("Success, directory exists");
						return true;
					}
				}
				if (sType.equals("file")) {
					SandyUI.addToLog("testing existence of file");
					if (fTest.isFile()) {
						SandyUI.addToLog("Success, file exists");
						SandyUI.addToLog("testing if file is executable");
						//if (fTest.canExecute()) {
							SandyUI.addToLog("Success, file is executable");
							return true;
						//}
					}
				}
				addToLog("problem with "+sType+" "+sTest+"   ");
				addToLog("Are the necessary files present with the correct permissions?");
				fatalError = true;
				return false;

On my laptop, running the application from within eclipse or from a jar, the checks behave correctly. On my boss's laptop, running from a jar, the check for executability fails even though the file is executable. What is up with that?