0

Alrighty, so I'm working on making a .jar for a client for a little game and I know how to use everything and have done this before, on windows, now i'm on a mac. This shouldn't make a difference but incase you wanted to know, there you go.

Now, I have a folder in eclipse named client, now normally the client.java is the main class but there is another named EGUI, this has the "public static void main(String[] args)", but in my client.java file, it also has a method like this:

 public static final void main(String args[])
{
    try
    {
        anInt957 = 0;
        anInt958 = 0;
        method52(false);//highmem
        aBoolean959 = true;//members
        signlink.storeid = 32;
        signlink.startpriv(InetAddress.getLocalHost());
        client client1 = new client();
        client1.method1(503, false, 765);
        setserver(args[0], "5555");
        return;
    }
    catch(Exception exception)
    {
        return;
    }
}

I guess my question is, does the "final" make it the main file? Or would it still be the EGUI, which looks like this:

import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class EGUI
{ 
public static void main(String args[])
{
                client.main(new String[] {
            "127.0.0.1", "127.0.0.1", "127.0.0.1"
        });
    }
}

So, what i'm asking for is, why is it that when I'm setting the main file to EGUI, it isnt working? the applet opens up, but I keep getting an "error connecting to server" message every time, when I run it through terminal by copying the run.bat info and pasting that, it works perfectly! Any help is greatly appreciated!

Sully Brooks
  • 425
  • 4
  • 8
  • 21
  • It look much like that your concrete problem is that you're trying to let the applet connect to a server which is on IP address 127.0.0.1. But... that's the loopback interface address. Shouldn't you provide the real IP address of the server? This has in turn nothing to do with `main()` methods. – BalusC Dec 29 '12 at 23:02
  • @BalusC, Well this is supposed to be my own personal testing client for when i'm coding the source of the server (the actual game), I'm wanting it to connect to my local Ip because it's not gone public yet. – Sully Brooks Dec 29 '12 at 23:04

1 Answers1

1

public static void main(String args[]) means you can execute the class from the commandline. The final keyword means the method cannot be overridden by a sub class.

In your case this does not make it the jar's main execution class. The main class is set in META-INF/MANIFEST.MF. Normally it should have a line:

Main-Class: classname

but then with the actual class.

So open the jar with a zip program, and check MANIFEST.MF.

Your client.java has a main method, for testing purposes I suppose.

asgoth
  • 35,552
  • 12
  • 89
  • 98