Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

renameTo() problem second part

Posted on 1998-06-20
10
Medium Priority
?
324 Views
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.
0
Comment
Question by:johnh619
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 6

Expert Comment

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

Author Comment

by:johnh619
ID: 1223439
Edited text of question
0
 
LVL 5

Expert Comment

by:fontaine
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:johnh619
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/
ResearchTriangle/Lab/6810








0
 

Author Comment

by:johnh619
ID: 1223442
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
 
LVL 5

Expert Comment

by:fontaine
ID: 1223443
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
 
LVL 2

Expert Comment

by:aziz061097
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.

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

has some info on Signing .
0
 

Author Comment

by:johnh619
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.
0
 

Author Comment

by:johnh619
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?
0
 
LVL 5

Accepted Solution

by:
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:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

636 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