I have created a program in Java that uses an FTP connection to download files. It works just fine when I run it in Eclipse. However, when I export the project to an executable JAR file, the program does not connect to the FTP server, it connects only if I disable Windows Firewall.
How can I programmatically add an exception to this JAR file in the firewall so that the user would not have to turn off the firewall to use my program?
Answer
Solved it, added "netsh advfirewall set global StatefulFTP disable" via command promp, the code:
try {
Process p = Runtime.getRuntime().exec("netsh advfirewall set global StatefulFTP disable");
p.waitFor();
BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null) {
System.out.println(line);
line = reader.readLine();
}
} catch (IOException e1) {
} catch (InterruptedException e2) {
}
Comments
Post a Comment