PDA

View Full Version : [Java] Problema di compilazione


Darker
31-03-2009, 15:15
Ciao a tutti :)

Ho un problema con un codice java. Il suddetto codice viene compilato ed eseguito senza problemi su tutte le macchine eccetto la mia :|

Se compilo via DOS ottengo un
MyServer.java:53: cannot find symbol
symbol : class Socket
location: class Server.MyServer
Socket s = new Socket(port, rootDir);
^
MyServer.java:53: cannot find symbol
symbol : class Socket
location: class Server.MyServer
Socket s = new Socket(port, rootDir);
^
2 errors

Con il "run" di eclipse invece ho un "The Selection does not contain a main type in Eclipse".

Qualche consiglio?

Questo il codice:

package Server;

import java.io.BufferedReader;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class MyServer {

public static void main(String[] args) throws Exception {

int port = 80; //Porta predefinita
File rootDir = new File("./tmp/"); //Path predefinita
BufferedReader cfgfile = null;

try {
cfgfile = new BufferedReader(new InputStreamReader(new FileInputStream(new File("file.cfg"))));
String line = cfgfile.readLine();
if(line==null)
throw new EOFException();
StringTokenizer st = new StringTokenizer(line);
String param = st.nextToken();
String argum = st.nextToken();
if(param.equalsIgnoreCase("port")){
port = Integer.parseInt(argum);
line = cfgfile.readLine();
if(line!=null){
st = new StringTokenizer(line);
if(st.hasMoreTokens()){
String temp = st.nextToken();
if(st.hasMoreTokens()){
argum = st.nextToken();
param = temp;
}
}
}
}
if(param.equalsIgnoreCase("root")){
rootDir = new File(argum);
}
cfgfile.close();
}catch(Exception e){
e.printStackTrace(System.err);
cfgfile.close();
}

if(!(rootDir.exists())){
rootDir.mkdirs();
}

Socket s = new Socket(port, rootDir);
s.start();

}

}



Ultima java JDK x64 su Vista x64 Hp

Grazie :)

wingman87
31-03-2009, 15:26
Non hai fatto l'import di java.net.Socket

agente mm8
31-03-2009, 17:09
Infatti... sei proprio sicuro che sulle altre macchine funziona??

Darker
31-03-2009, 20:24
Ho importato anche quello e non va ugualmente.

Si, sono certo che sulle altre macchine funzioni. D'altronde ho i file già compilati (sulle altre macchine) e anche l'esecuzione sul mio non ne vuole sapere.

Oltre a questo file java ce ne sono altri 3, ne ho postato solo uno: ho pensato che non aveva senso postare anche gli altri dato che il problema è simile :)

Edit: se compilo tutti i file in un colpo funziona anche a me. Non capisco perché sugli altri pc compilava con un file alla volta ed invece ora no. Mah :|