Reputation: 215
I had a problem a couple of days ago where I was getting a Permission denied: connect when using Javamail to send an e-mail using our local mail server. For reference it can be found here: JavaMail API to iMail -- java.net.SocketException: Permission denied: connect. The solution was to add "-Djava.net.preferIPv4Stack=true" to my project's VM Options.
I'm getting the same error codes after building the project and trying to run the .jar file outside of NetBeans. The project works as intended from inside the NetBeans IDE.
I have searched around the questions here, Google, and read through some Javamail FAQs. To be honest, I really don't know what I am looking for and figure that I am just missing something.
I'm using NetBeans 7.2, Java 7, and Windows 7. The dist folder for my project has the .jar file and the dist\lib folder contains mail.jar.
Any ideas on why I would be getting that error again? Thank you again for any help/information.
Upvotes: 1
Views: 1804
Reputation: 29971
How are you running your program?
If you run it with "java -jar myprog.jar", use "java -Djava.net.preferIPv4Stack=tru -jar myprog.jar".
If you run it by double clicking the jar file or something like that, you might need to set the property in your code, by adding System.setProperty("java.net.preferIPv4Stack", "true");
Upvotes: 1