Nullpointerexception
thomas2789
Messages postés
2
Statut
Membre
-
thomas2789 Messages postés 2 Statut Membre -
thomas2789 Messages postés 2 Statut Membre -
Bonjour,
Donc voila j'ai un petit problème , survenu à l'installation de mon Runnable
[COLOR="Blue"]Et donc voici l'erreur :[/COLOR]
[COLOR="Red"]Exception in thread "Thread-3" java.lang.NullPointerException
at fenêtre.CCommunication.position(CCommunication.java:87)
at fenêtre.CCommunication.run(CCommunication.java:102)
at java.lang.Thread.run(Thread.java:619)
[/COLOR]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[CODE]public class CCommunication implements Runnable{
protected String a;
MyFenetre f;
private BufferedImage destinationImage;
CSysteme sys ;
int lu;
public CCommunication(CSysteme sy)
{
this.sys=sy;
}
public void position()
{
try {
//connexion();
// Socket socket = new Socket("localhost", 45001);
//InputStream in = socket.getInputStream();
byte[] tab = new byte[20];
// int lu = in.read(tab);
lu = sys.sock.entreeSocket.read(tab);// c'est ici qu'il y a un probléme avec la variable sys mais je comprend pas
a = new String(tab, 0, lu);
System.out.println(a);
sys.AffichePosition();
} catch (IOException ex) {
Logger.getLogger(CCommunication.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void run() {
while(true)
{
position();
}
}
}[/CODE]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[CODE]
public class Main {
// MaSocket sock = new MaSocket("172.16.157.11",45001);
CSysteme sy;
/**
* @param args the command line arguments
*/
@SuppressWarnings("static-access")
public Main() throws UnknownHostException{
CCommunication com = new CCommunication(sy);
MyFenetre f = new MyFenetre();
f.setSize(800,550);
f.setVisible(true);
f.addKeyListener(f);
// com.position();
Thread th ;
th = new Thread(com);
th.start();
// sock.receptionFichier();
// f.ReceptionPosition();
}
[/CODE]
Donc voila j'ai un petit problème , survenu à l'installation de mon Runnable
[COLOR="Blue"]Et donc voici l'erreur :[/COLOR]
[COLOR="Red"]Exception in thread "Thread-3" java.lang.NullPointerException
at fenêtre.CCommunication.position(CCommunication.java:87)
at fenêtre.CCommunication.run(CCommunication.java:102)
at java.lang.Thread.run(Thread.java:619)
[/COLOR]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[CODE]public class CCommunication implements Runnable{
protected String a;
MyFenetre f;
private BufferedImage destinationImage;
CSysteme sys ;
int lu;
public CCommunication(CSysteme sy)
{
this.sys=sy;
}
public void position()
{
try {
//connexion();
// Socket socket = new Socket("localhost", 45001);
//InputStream in = socket.getInputStream();
byte[] tab = new byte[20];
// int lu = in.read(tab);
lu = sys.sock.entreeSocket.read(tab);// c'est ici qu'il y a un probléme avec la variable sys mais je comprend pas
a = new String(tab, 0, lu);
System.out.println(a);
sys.AffichePosition();
} catch (IOException ex) {
Logger.getLogger(CCommunication.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void run() {
while(true)
{
position();
}
}
}[/CODE]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[CODE]
public class Main {
// MaSocket sock = new MaSocket("172.16.157.11",45001);
CSysteme sy;
/**
* @param args the command line arguments
*/
@SuppressWarnings("static-access")
public Main() throws UnknownHostException{
CCommunication com = new CCommunication(sy);
MyFenetre f = new MyFenetre();
f.setSize(800,550);
f.setVisible(true);
f.addKeyListener(f);
// com.position();
Thread th ;
th = new Thread(com);
th.start();
// sock.receptionFichier();
// f.ReceptionPosition();
}
[/CODE]