The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

AWT Desktop Open

I'm attempting to open a pdf help file on button click. However I get the "File not found" error on button click. None of the JOptionPanes show, leading me to below it isn't even catching the error. Error line is the Desktop.getDesktop() line. Both the listener and the error code are below. The package structure leading to the file I'm accessing is si/documentation/HELP STUFF.pdf. Thanks in advance!

Re: AWT Desktop Open

Thanks Tjstretch. Now I"m getting a new error on the same line, null pointer reference. I'm not sure where this would be coming from, unless somehow the Desktop is returning null. I haven't used the AWT Desktop before, so I'm not familiar with how it works very well. Stack trace below (Also Tjstretch, what was the reasoning behind that backslash? Why did that work?)

Re: AWT Desktop Open

Solved it. I was so used to seeing special character code I didn't notice it at first. The ClassLoader.getSystemResource(path).getFile() was replacing all spaces with %20. I'm assuming this is a URL property I didn't know about. So running filename = filename.replace("%20"," ") fixed the path, and thus found the file.

Re: AWT Desktop Open

I am not sure I been in working out of Windows too long, currently if i remember that you are not allowed spaces for path names in Linux. Then again I should just fire up the VM ware for CentOS and test it.