Forums Register Login

Why this is not working ????

+Pie Number of slices to send: Send
hi ther,,,

when i try to run n compile this prg in browser it says Internal Server Error 500 java.lang.ClassNotFoundException: Unable to find class java.io.FilePermission
if i comment
FilePermission fp = new FilePermission("/test/test.txt","delete");
java.lang.NoSuchMethodError: java.io.File: method
getCanonicalFile()Ljava/io/File; not found

can anyone solve this problem ...
i have tested this code in Windows-2000 n Solaris...the webserver which i am using is JavaWebServer2.0....
(this code is perfectly working on console)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DemoTest extends HttpServlet {

public void service(HttpServletRequest req,HttpServletResponse res) {




try {

PrintWriter out = res.getWriter();

FilePermission fp = new FilePermission("/test/test.txt","delete");

File f = new File("/test/test.txt");

f = f.getCanonicalFile();

if(f.delete()){

out.println("File Deleted");



}else{

out.println("Error");



}





}catch(Exception e){


e.printStackTrace();


}



}



}

Rao
+Pie Number of slices to send: Send
This is only a guess at the moment, but File.getCanonicalFile() and the FilePermissions class have both only existsed since 1.2
It might be that you are compiling them with a post-1.2 JDK but then attempting to run with a pre-1.2
Could that be it? What version of the JDK deos the JavaWebServer use?
Dave.
+Pie Number of slices to send: Send
no sir,

the version of JDK is 1.2..... n i dont have any other versions installed .......
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 647 times.
Similar Threads
Creating file on server - java.io.FilePermission - access denied
IO package
How to read data from a text file
Canonical vs Absolute
Deleteing a file
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:56:23.