Dominic Siano

Greenhorn
+ Follow
since Jan 05, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dominic Siano

Thanks for the input. I will try it with a webserver and see if I still get the same problem.
12 years ago
Anybody ever come across this issue ?

Is there a better more generic way of accessing files from an applet. Like I mentioned
in my post I am trying to avoid hard coding server names and paths in my code.

I thought that this code would do the trick but when it comes time for the call
of desktop = Desktop.getDesktop(); desktop.open(docToOpen); spaces in file name
cause the file name to be found.

File x = new File(this.getCodeBase().getPath());
String xx = x.getPath() + File.separator + "upload" + File.separator;
uploadDir = xx;

Thanks....
12 years ago
I was able to get the debugger to work with the following policy file:

grant {
permission java.lang.RuntimePermission "accessClassInPackage.sun.jdbc.odbc";
permission java.util.PropertyPermission "file.encoding", "read";
};

In the Netbeans debugger I added the following line to the VM options Run Catagory:
-Djava.security.policy=C:\KnowledgeRepository\build\classes\applet.policy

I guess this was good enough to get me debugging my code, but if someone can provide input
as to why the applet will work after it has been signed and run from a browser but not in the netbeans debugger ?

One thing I forgot to mention in my last post was the following; after I compile and create the jar
I sign it and copy it into the directory where the applet if running from in the debugger. If I create
the html doc here and run from the browser all is good. In the debugger it will not work unless I
have the policy file. There seems to be an issue with the appletviewer in netbeans. The same project
debugs fine on another mach without any policy file.


Thanks
12 years ago
I get the following error when I try and degbug my applet from the netbeans IDE 6.1.

Error: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)

The above error is created when the following code is executed:

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
.....

I have signed the applet and it will work fine in a webbrowser launced from html. I am not sure why the applet
gives me this problem from the debugger.

I really need to be able to debug the code. Any ideas ?

Thanks
12 years ago
Hello,

For some reason when uploadDir is set to commented value I am only able to open files where the names
do not contain spaces. For example a doc named "Test Me.doc" will not be found to load but if the file is named "TestMe.doc"
there will be no issues. Please note that this applet is not being run from a webserver; it is being executed from a shared drive on
a windows server.

Code That works......
String launchLocation = this.getCodeBase().getFile();
char drive = launchLocation.charAt(1);
String driveLetter = String.valueOf(drive);
uploadDir = driveLetter + ":/NY_GEIT_ETMS/GPS_KNOWLEDGE/upload/";

Code That will not allow spaces in file names.
//uploadDir = File.separator + File.separator + "acntnyc032" + File.separator + "dept" + File.separator + "NY_GEIT_ETMS" + File.separator + "GPS_KNOWLEDGE" + File.separator + "upload" + File.separator;


Code which launches doc
private void DocumentButtonMousePressed(java.awt.event.MouseEvent evt) {
// Open Document Code Here


String PATH = uploadDir;
String completePath = PATH + currentDocument;
File docToOpen = new File(completePath);

Desktop desktop;
if (Desktop.isDesktopSupported()) {
try {
desktop = Desktop.getDesktop();
desktop.open(docToOpen);
}
catch (IOException ioe) {
ioe.printStackTrace();
}
}
}


I have played around with the below code but it also gives me an issue loading files with spaces in the name.
//File x = new File(this.getCodeBase().getPath());
//String xx = x.getPath() + File.separator + "upload" + File.separator;
//uploadDir = xx;
//System.out.print(xx);


Any help would be great. I am trying to avoid using drive names in the code at all cost.

Thanks


12 years ago