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 :)
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 :)