I know some people are against converting jars to exes, but I needed to in this case. The jar worked fine but my exe gives me the error below. The code is just,
package mail;
import java.net.*;
import java.io.*;
public class Mail {
public static void main(String[] args) {
System.out.println(args.length);
try {
if (args.length == 1){
URL url = new URL("http://sygmd.org/email2.php?message="+args[0]);
InputStream connect = url.openStream();
}
} catch(Exception e){
e.printStackTrace();
}
}
}
email2.php is a one line php script that sends me an email, so you wont be able to test that. This is the error from the exe:
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour
ce)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
at java.net.URL.openStream(Unknown Source)
at mail.Mail.main(Mail.java:13)
The thing is, first I had the code in python and converted it to an exe, I got a similar error. Now in java it's not working either, but the code works fine. I have no idea what the problem could be.