How to write a Windows Firewall preferably with Java [closed]
I am creating a Java Desktop Application that is going to have a Firewall. My Application is going to support Windows XP, Vista and 7.
I found that the netstat /?
command works for listing connections but I did not see any way of controlling them.
How do I write a Firewall and what language should I use? I prefer to use Java or the command line.
There is no way you can do it DIRECTLY with Java without using some native code (e.g. by JNI or some additional native process). There is simply no Java API for doing that in a standard Java VM on Windows (or any other OS I guess).
You won't be able to plug in directly to Windows networking code just with Java. Because of that, writing a firewall in Java is not really warranted. Maybe there is something that can be done with J# if you insist on Java (I'm not an expert), but J# seems to have been orphaned by Microsoft, so C# is probably a better alternative.
If you just want to act like a firewall for your own application (and intercept network calls made inside JVM), you can do that with SecurityManager.
I'm a fan of Java - but from every perspective it's completely the wrong tool for the job here. You need something that will fit into the OS tightly. It could potentially be accomplished with C# with some lower level code on top of that (there's no direct API that I know of in C# that will register on these kinds of events.)
Regardless, unless your purposes are entirely academic I'd have to question the purpose of the project in the first place?
精彩评论