This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes open a .exe in java (DLL Problem) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "open a .exe in java (DLL Problem)" Watch "open a .exe in java (DLL Problem)" New topic
Author

open a .exe in java (DLL Problem)

noddy j
Greenhorn

Joined: Feb 19, 2001
Posts: 2
hi
i have a servlet code which is opening a .exe file from the
server on to the client machine.
the code written below works fine to open the .exe from server
on to the client machine.
but it asks for a .DLL file which is already present in the same
folder as the .exe.
howeever , when this .exe is opened by double clicking on it
it opens fine without any DLL problem.
but when accessed thru this servlet it gives error' DLL not found'. but the DLL is already present in the same folder as the .exe file. if not ,where should the DLL be?
so what is the problem.
pls help .
thks
Kamal J
kamaalj@usa.net

here is the code)

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class filedownload extends HttpServlet
{
public void doGet(HttpServletRequest sReq ,HttpServletResponse sRes)
throws IOException,ServletException
{

String fileWanted="nowork.exe"
String pathOfFile = "c:/"+ "Downloadablefiles"+"\\" + fileWanted;

//Downlaodablefiles is the name of folder where nowork.exe is
File F = new File(pathOfFile);
sRes.setContentType("application/x-msword");
//the next statement is the most IMPORTANT statement
sRes.setHeader("Content-Disposition", "attachment;filename=\"" + fileWanted +"\"");
ServletOutputStream out = sRes.getOutputStream();
InputStream in = null;
try
{
in = new BufferedInputStream(new FileInputStream(F));
int ch;
while ((ch = in.read()) !=-1)
{
out.print((char)ch);
}
}
catch(Exception e)
{
System.out.println(e.toString());
}
finally
{
if (in != null) in.close();
}

}
}
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"noddy j",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: open a .exe in java (DLL Problem)