[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

renameTo() problem second part

I would like to submit this again;to restate: I have the
code for a applet which will rename a directory when a
button is pushed. I believe the problem is in the action
event performer which is the last part. Ragnar thought
I was going to input from the command line but this is
not the way I meant. The button does work and readout
of the action but no action is performed to rename the
directory. This ends restatement. This time I uploaded the
.java file to http://users.aol.com/baywooddr/Choosing.java
Ragnar answer the first part, perhaps he can try again;
the suggestion he gave did not solve the problem.
0
johnh619
Asked:
johnh619
1 Solution
 
gadioCommented:
If you can repeat your original question and describe the problem exactly it would be helpfull.
0
 
johnh619Author Commented:
Edited text of question
0
 
fontaineCommented:
Are you signing the applet? If you don't do it, you will not be able to rename a directory,
which is a local resource and is outside of the Java sandbox.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
johnh619Author Commented:
Fontaine I uploaded a file Choosing.java to http://users.aol.com/
baywooddr/ and I copied part of it. I found a renameTo example
and the guy had put the renameTo method in the system.out.printlin parentheses. I did not know I could do that
but it works that way. I really dont know about signing it
and I will have to look that up. The next problem I resubmitted
after I got this part working. I compiled it and put it in a
html page and it would not start properly. I thought maybe it
should have more work in the applet part about standalone
programs. So I guess I might email you again later after I
read up on this signing idea. Thanks
I also uploaded Choosing.java to http://www.geocities.com/
ResearchTriangle/Lab/6810








0
 
johnh619Author Commented:
When you signing the applet did you mean like a method signature?
I looked up signature and found this table saying
z=boolean
b=byte
and so on
this is a method signature I believe. I did not see reference
to signing an applet in my books.
0
 
fontaineCommented:
Here is a link that provides you with information on this:

http://www.geocities.com/SiliconValley/Vista/1337/java-s1.html

With an application, you can access local resources such as files, connect to an arbitrary
server, i.e. do all you would do with another language such as C++. An applet however,
has some restrictions that prevent bad guys to do bad jokes such as grab confidential
data from your disk, or whatever. An applet can't connect to an arbitrary host, but only
the machine that has served the applet and does not have access to local resources.
To gain these accesses, you need to sign the applet, what opens the security sandbox
the applet works in. This page explains you that:

http://www.javasoft.com/products/jdk/1.2/docs/guide/security/spec/security-spec.doc1.html

0
 
aziz061097Commented:
Hi John,

       Yes your program works if you do not run it from the browser. As fontaine said ,You need to sign the Applet before you can load in the browser. I converted your program to Applet instead of running as an application (Frame) if that is what you are trying by doing Standalone??? . It works fine when run from appletviewer but will and does give Security exceptions when the buttons are clicked in browser, since browsers have security restrictions that can not do operations on the Harddisk (local resources) .

           The applet will work after you sign it, which eases the security of the browsers.

http://www.geocities.com/SiliconValley/Park/9841/sign.html

has some info on Signing .
0
 
johnh619Author Commented:
I guess also I dont understand the idea of interfaces also.
It seems if I start with extend from frame then I do not get
the error message saying the type File was in the declarations
or top of the program. If I entend applet I do get an error
at line
File f1= new file ("path")
saying that File was not recognized. I am presently reading
about multiple inheritance and it says I can have an interface
made of methods which will let me inherit from applet and
Frame or should it be applet and io classes.
In any case I shall read the file about signing which I did not
know existed until you told me. Perhaps then this may be the
end of this questioning.
0
 
johnh619Author Commented:
I can see now since reading up on signing that it is no wonder
that my applet would not run in the browser since it involved
file security. I of course at present think that making it a
stand alone java applet would be easier than trying to get a
signing certicate. I am a disabled veteran and this is my hobby
and is not a money making adventure. So now I can see how the
standalone idea becomes interesting. But really I am assuming
by standalone that they mean the applet does not require a
browser. I have a copy of java cafe and jbuilder and they support
creating an application I believe so I will try to make the
standalone applcation. Or I could let my user download a copy
of java.exe I suppose since it is only 5120 bytes. I am right
about that?
0
 
fontaineCommented:
Whenever an applet tries to access local resources or connect to a machine that is not
the one that has served it, signing is required.

Info on the security model:
http://www.javasoft.com/products/jdk/1.2/docs/guide/security/spec/security-spec.doc1.html 

Info on signing:
http://www.geocities.com/SiliconValley/Vista/1337/java-s1.html

You extended Frame when you wrote your prog. as an application.
-> no security problem, file accesses are OK

To write an applet, you extend java.applet.Applet. With an applet, file accesses are not
permitted, except if you sign it (see above).

Multiple inheritance does not exist in Java. An interface simply defines a set of method signatures your class has to implement. They don't have a default implementation.
If you write:

public class Test extends AClass implements AnInterface {
 //...
}

all the methods of AnInterface have to be present in the code of Test, but you have to
implement them yourself, you are not inheriting any default implementation like in class
inheritance.

Your users only need the classes(.class) you have developed in order to run the app. as
well a Java virtual machine. The users should consult their machine vendor (HP, DEC, etc.)
in order to get one (for free). If MyClass is the name of the '.class' that contains the main()
of the app., users will typically type:

java MyClass

to run the application. I guess you should have some doc. with the IDE that explains you
how to distribute what you have created.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now