[Webinar] Streamline your web hosting managementRegister Today


renameTo() problem second part

Posted on 1998-06-20
Medium Priority
Last Modified: 2012-08-13
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.
Question by:johnh619

Expert Comment

ID: 1223438
If you can repeat your original question and describe the problem exactly it would be helpfull.

Author Comment

ID: 1223439
Edited text of question

Expert Comment

ID: 1223440
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.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.


Author Comment

ID: 1223441
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/


Author Comment

ID: 1223442
When you signing the applet did you mean like a method signature?
I looked up signature and found this table saying
and so on
this is a method signature I believe. I did not see reference
to signing an applet in my books.

Expert Comment

ID: 1223443
Here is a link that provides you with information on this:


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:



Expert Comment

ID: 1223444
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.


has some info on Signing .

Author Comment

ID: 1223445
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.

Author Comment

ID: 1223446
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?

Accepted Solution

fontaine earned 100 total points
ID: 1223447
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:

Info on signing:

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

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.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question