Solved

Using java to download and run files in a applet

Posted on 2007-11-22
2
230 Views
Last Modified: 2013-11-24
I am currently developing a project to match with an existing one and I'm attempting to create a web-based java applet that downloads a text file then opens it. I've attempted to do this already and failed.

The method I tried for downloading is (only a SMALL bit to allow better understandment) :
"URL url = new URL(address);
out = new BufferedOutputStream(
new FileOutputStream("C:\\temp\\" +localFileName));
conn = url.openConnection();
in = conn.getInputStream();"

I had a basic text for the applet using this:

"public void paint(Graphics g)
     {
      g.drawString("Please wait..",20,20);
      g.drawString("Retrieving file.",20,40);
}"

However, only the text bit showed. The downloading and running code simply didn't do its job. It passed compile and it works fine when I run the .class using batch, but the minute I jar it, it won't even run using a batch file nor applet. Basically, I want to know how to make a proper .jar applet that downloads and runs a file from a chosen URL (which will be in the same directory as the jar, on the same webserver).
0
Comment
Question by:HiTechFail
2 Comments
 
LVL 17

Expert Comment

by:contactkarthi
ID: 20336223
0
 
LVL 2

Accepted Solution

by:
HiTechFail earned 0 total points
ID: 20336664
They help a little, but still does not work after implementing into an applet.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 77
Java. Convert method from recursion based to iteration based ( loop based ) 6 77
GUI builder for Eclipse? 8 27
Windows 10 and JDK 7 7u85 4 33
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now