Results 1 to 7 of 7
Thread: Error While Opening A PDF file
- 06-07-2010, 03:41 PM #1
Error While Opening A PDF file
I am getting this error . . .
test.java:5: unreported exception java.io.IOException; must be caught or declared to be thrown
Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler Tic Tac Toe itemStrategy.pdf");
^
1 error
java.lang.NoClassDefFoundError: test
Caused by: java.lang.ClassNotFoundException: test
at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
Could not find the main class: test. Program will exit.
Exception in thread "main"
Code is
or Is there any alternative way to open a file from directory other than images etc ???Java Code:public class test { public static void main (String[] args) { Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + "Guide.pdf"); } }Last edited by Cluster Storm; 06-07-2010 at 03:53 PM.
- 06-07-2010, 04:38 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
It's not erroring trying to open the file, it's not even compiling.
This:
unreported exception java.io.IOException; must be caught or declared to be thrown
is a compilation error.
You need to either catch or throw the exception.
- 06-07-2010, 05:16 PM #3
As you said you need to either catch or throw the exception . .
I use try and catch block . . .
Now i am getting this compile time error . . .
test.java:14: reached end of file while parsing
}
Modified code is :
This problem is appearing now, before that when i run first time it work properly . . . but now it is giving me an error . . .Java Code:public class test { public static void main ( String[] args ) { try { Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + "Tic Tac Toe itemStrategy.pdf" ); } catch ( Exception e ) { System.err.print( e.getMessage() ); } }
Is there any alternative way to do such type of task ???
- 06-07-2010, 05:38 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Again...compilation error.
Count your brackets.
- 06-07-2010, 05:43 PM #5
Ok i recover this error . . . but the file is not opening ??? What i do ?? You don't have any alternate way to open a file ??
Please
- 06-07-2010, 05:54 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
No idea what it is you're trying to do, frankly, but that exec looks flaky.
You could have a look at the runtime traps article.
It's generally best to split an exec call up into a String[], so (from the article):
Java Code:String[] cmd = new String[3]; cmd[0] = "cmd.exe" ; cmd[1] = "/C" ; cmd[2] = "some command";
- 06-07-2010, 06:03 PM #7
Similar Threads
-
Jre upgrade Issue :java.util.zip.ZipException: error in opening zip file
By selvakumar.velmurugesan in forum New To JavaReplies: 0Last Post: 10-27-2009, 05:20 AM -
java.lang.Error: Error opening DSound for capture
By NARs in forum NetworkingReplies: 1Last Post: 10-26-2009, 04:38 PM -
Opening a custom proyect file
By janpol1 in forum EclipseReplies: 0Last Post: 02-04-2009, 02:29 PM -
Error opening socket: java.net.ConnectException: Connection refused: connect
By somersst in forum Java ServletReplies: 3Last Post: 01-26-2009, 05:30 PM -
Problem in opening a file
By Raghav kv in forum New To JavaReplies: 1Last Post: 08-11-2007, 01:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks