Java problem: Don't know how to compile with the sdk

acemcmac

Lifer
Mar 31, 2003
13,712
1
0
import java.net.*;
import java.io.*;


public class IPFinder
{
public static void main(string[] args) throws IOException
{
String host;
BufferedReader input =
new BufferedReader( new InputStreamReader(System.in));

System.out.println("\nEnter host name: ");
host = input.readLine();
try
{
InetAddress address=
InetAddress.getByName(host);
System.out.pringln("IP Address: " + address);
}
catch (UnknownHostException e)
{
System.out.println("Could not find " + host);
}
}
}
java -classpath TCPServer.java runs with no problem

java TCPServer replies
"Exception in thread "main" java.lang.NoClassDefFoundError: TCPServer


I am sure I'm compiling this wrong... I have the j2sdk-1_3_1_15-windows-i586.exe installed and I'm just copying off of handouts... can someone tell me what I'm doing wrong?
 

znaps

Senior member
Jan 15, 2004
414
0
0
1) "java -classpath TCPServer.java" should produce an error.

2) The "java" command runs compiled .class class files
The "javac" command compiles java .java source files.

3) Where is the TCPServer.java / .class file? You showed us the source for another class, IPFinder.
 

acemcmac

Lifer
Mar 31, 2003
13,712
1
0
I dunno what I'm doing.... I just need to get the file above, running, hell or high water in a command window by 7:00...... I know nothing about java... could you guys please just tell me what to do ;) ?
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
Originally posted by: acemcmac
I dunno what I'm doing.... I just need to get the file above, running, hell or high water in a command window by 7:00...... I know nothing about java... could you guys please just tell me what to do ;) ?
If you don't know anything about java, why are you responsible for working with java source files?
 

znaps

Senior member
Jan 15, 2004
414
0
0
Type "javac IPFinder.java" and see if that creates a IPFinder.class file in the same directory.
 

acemcmac

Lifer
Mar 31, 2003
13,712
1
0
Originally posted by: znaps
Type "javac IPFinder.java" and see if that creates a IPFinder.class file in the same directory.

negative, even with the file named IPFinder.java.

Originally posted by: Kilrsat
Originally posted by: acemcmac
I dunno what I'm doing.... I just need to get the file above, running, hell or high water in a command window by 7:00...... I know nothing about java... could you guys please just tell me what to do ;) ?
If you don't know anything about java, why are you responsible for working with java source files?

good question, ask my prof. He wants this by 7
 

znaps

Senior member
Jan 15, 2004
414
0
0
negative, even with the file named IPFinder.java.

Is that all the info you're gonna give? Man, if you want help post all the error messages you see.
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
Working from memory - try

javac TCPServer.java, when you're in the same directory as the file. You may need to edit your PATH for access to the javac binary. Or

c:\jdk1.3.1_15\bin\javac path\to\your\file\TCPServer.java

and tell us the error.
 

znaps

Senior member
Jan 15, 2004
414
0
0
type "javac IPFinder.java" and see if that creates a IPFinder.class file in the same directory.

type it exactly as I said, not "javah..", not "javac -classpath" and not "java ..."


Then type "dir" and see if there is an "IPFinder.class" file.

If there is, type "java IPFinder"

 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Are you sure the name of the file and the name of the class are the same? As in, for the class IPFinder you should have a file called IPFinder.java.

Also, time to dump the way old jdk. It's two major versions old :p
 

acemcmac

Lifer
Mar 31, 2003
13,712
1
0
Originally posted by: znaps
type "javac IPFinder.java" and see if that creates a IPFinder.class file in the same directory.

type it exactly as I said, not "javah..", not "javac -classpath" and not "java ..."


Then type "dir" and see if there is an "IPFinder.class" file.

If there is, type "java IPFinder"

HOORAYYYY THE DAY IS SAVED!!!!
 

znaps

Senior member
Jan 15, 2004
414
0
0
Now try and get yourself an editor with syntax highlighting..that'll help you learn faster.