Solved

Using java to download and run files in a applet

Posted on 2007-11-22
2
231 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 79
maven project error 5 54
split string containing \r\n in Java 46 43
nextBoolean(double p) for Random class 3 40
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

813 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

10 Experts available now in Live!

Get 1:1 Help Now