Solved

Using java to download and run files in a applet

Posted on 2007-11-22
2
229 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
Comment Utility
0
 
LVL 2

Accepted Solution

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
for loop with Set 4 45
pairs challenge 5 44
groovy example issue 10 65
JAVA part two 5 39
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

772 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

11 Experts available now in Live!

Get 1:1 Help Now