|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Jun 2001
Città: London (UK)
Messaggi: 1788
|
[Java] Problema di compilazione
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 Codice:
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 Qualche consiglio? Questo il codice: 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(); } } Grazie ![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Nov 2005
Messaggi: 2773
|
Non hai fatto l'import di java.net.Socket
|
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Mar 2008
Messaggi: 401
|
Infatti... sei proprio sicuro che sulle altre macchine funziona??
|
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Jun 2001
Città: London (UK)
Messaggi: 1788
|
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 :| Ultima modifica di Darker : 31-03-2009 alle 19:57. |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 01:55.