| | |
JAR works bue EXE doesn't
![]() |
•
•
Join Date: Dec 2008
Posts: 47
Reputation:
Solved Threads: 0
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,
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.http://www.protocol.http.HttpURLConn...Client(Unknown
Source)
at sun.net.http://www.protocol.http.HttpURLConn...onnect(Unknown Sour
ce)
at sun.net.http://www.protocol.http.HttpURLConn...onnect(Unknown Source)
at sun.net.http://www.protocol.http.HttpURLConn...Stream(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.
Java Syntax (Toggle Plain Text)
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.http://www.protocol.http.HttpURLConn...Client(Unknown
Source)
at sun.net.http://www.protocol.http.HttpURLConn...onnect(Unknown Sour
ce)
at sun.net.http://www.protocol.http.HttpURLConn...onnect(Unknown Source)
at sun.net.http://www.protocol.http.HttpURLConn...Stream(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.
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
0
#2 26 Days Ago
Your connection appears to be refused:
java.net.ConnectException: Connection refused: connect
I tested your url, and I think it worked. I just wrote "Hey there" as the message arguments, so you may get an email with that or maybe not. I would attempt a step-by-step debugging of your code and try to determine exactly where the exception was thrown.
java.net.ConnectException: Connection refused: connect
I tested your url, and I think it worked. I just wrote "Hey there" as the message arguments, so you may get an email with that or maybe not. I would attempt a step-by-step debugging of your code and try to determine exactly where the exception was thrown.
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
0
#4 26 Days Ago
Ahh ok. Well, what I can tell you is that even though JAR and EXE files are both binary, the JARs run on the JRE which (correct me if I'm wrong) even has dedicated hardware. I understand your hands may be tied but maybe you may want to port your code over the the .NET architecture if you can't run on a JRE. There is a decent free C# compiler provided by microsoft and the diffferences are subtle.
If that is not an option, then you really may be painting yourself into a corner. The way the InputStream is implemented in your exe is obviously different then how it is implemented in your JAR. I know that I couldn't alter the linker to make it work, but that would need to happen, or override the inputStream class in such a way the exe file works. But who knows? There may be an easier way. Let me know if .NET is an option for you.
If that is not an option, then you really may be painting yourself into a corner. The way the InputStream is implemented in your exe is obviously different then how it is implemented in your JAR. I know that I couldn't alter the linker to make it work, but that would need to happen, or override the inputStream class in such a way the exe file works. But who knows? There may be an easier way. Let me know if .NET is an option for you.
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
0
#5 25 Days Ago
I have just run an EXE I made from your source with Excelsior JET, and it worked (Subject: Hello-from-EXE).
What are you using to create the EXE? There are many options, check out my article "Convert Java to EXE -
Why, When, When Not and How"
What are you using to create the EXE? There are many options, check out my article "Convert Java to EXE -
Why, When, When Not and How"
0
#6 24 Days Ago
Considering that you mentioned "email2.php", I assume you are running this from a hosted server? Well, does the "jar" run from the server? You say the "jar" worked, do you mean locally, or from that hosted server. Because I have the feeling that your site provider's firewall is refusing the connection, in which case you can try anything you want and it's not going to work.
Edit: Nevermind. I, finally, actualy looked at the code and see that script is a site the "program" is attempting to use.
Edit: Aaaaaaaarrrrrgggghhh and I also just now noticed that this thing was a year-long dead zombie thread.
Please do not resurrect old threads. I am fairly positive the OP is not still looking for answers from this thread, and that post is only a thinly veiled advertisement.
Edit: Nevermind. I, finally, actualy looked at the code and see that script is a site the "program" is attempting to use.
Edit: Aaaaaaaarrrrrgggghhh and I also just now noticed that this thing was a year-long dead zombie thread.
Please do not resurrect old threads. I am fairly positive the OP is not still looking for answers from this thread, and that post is only a thinly veiled advertisement.
Last edited by masijade; 24 Days Ago at 3:10 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
0
#7 24 Days Ago
Ahh, nevermind, I must have looked at a join date or something. Not, I repeat, not a zombie thread.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Other Threads in the Java Forum
- Previous Thread: MenuBar in swing not working :(
- Next Thread: Help! Adding an Image through a method.
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






