Understanding public static void main(String[] args)
<p>I am a PHP/Mysql programmer trying to learn Java and I'm stuck on how to complile a file with this in it:</p>

<pre><code>public static void main(String[] args)
</code></pre>

<p>Here is example code:</p>

<pre><code>import java.net.*;
import java.io.*;

public class GreetingClient
{
public static void main(String [] args)
{
  String serverName = args[0];
  int port = Integer.parseInt(args[1]);
  try
  {
     System.out.println("Connecting to " + serverName
                         + " on port " + port);
     Socket client = new Socket(serverName, port);
     System.out.println("Just connected to "
                  + client.getRemoteSocketAddress());
     OutputStream outToServer = client.getOutputStream();
     DataOutputStream out =
                   new DataOutputStream(outToServer);

     out.writeUTF("Hello from "
                  + client.getLocalSocketAddress());
     InputStream inFromServer = client.getInputStream();
     DataInputStream in =
                    new DataInputStream(inFromServer);
     System.out.println("Server says " + in.readUTF());
     client.close();
  }catch(IOException e)
  {
     e.printStackTrace();
  }
}
}
</code></pre>

<p>When run the try to use the javac command in Windows Command prompt to compile this from a .java file into a .class file to be called in a webpage, I get an error saying:</p>

<pre><code>bad class file: .\String.java
file does not contain class String
Please remove or make sure it appears in the correct subdirectory of the classpath.

public static void main(String[] args) {
</code></pre>

<p>If a compile a .java file like this one:</p>

<pre><code>import java.applet.Applet;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
public class applet_test extends Applet {
private InetAddress addr = null;
public void init() {
    try {
        addr = InetAddress.getLocalHost();
    }
    catch (UnknownHostException e) {
        System.exit(0);
    }
}
public InetAddress getLHost() {
    return addr;
}

}
</code></pre>

<p>I get no errors, the .java file compiles into a .class file and I am able to use the .class file in a webpage just fine.</p>

<p>Not sure what I'm doing wrong.</p>

<p>Thanks guys!</p>

<hr>

<p>Ok, so now, when I run this command:</p>

<pre><code>C:\ &gt; javac GreetingClient.java
</code></pre>

<p>I get this:</p>

<pre><code>GreetingClient.java:9: cannot find symbol
symbol  : method parseInt(GreetingClient)
location: class java.lang.Integer
  int port = Integer.parseInt(args[1]);
                    ^
GreetingClient.java:14: cannot find symbol
symbol  : constructor Socket(GreetingClient,int)
location: class java.net.Socket
     Socket client = new Socket(serverName, port);
                     ^
2 errors
</code></pre>

<p>Again, I only seem to get errors when running the javac command on a file with this line in it:</p>

<pre><code> public static void main(String[] args)
</code></pre>

<p>I know I'm missing something, any help would be appreciated it.</p>
