Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Simple Chat Problem

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I'm trying to make a small chat programm. It should not be perfect. ;-)

Here is the code I have already, unfortunately it is not working.
This is the Server:


This is the client:


Would be nice if someone coud help me.
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's start at the beginning: how can you tell it isn't working?
 
Moe Kennedy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Paul Clapham wrote:Let's start at the beginning: how can you tell it isn't working?



When I try to run one of these files, an error appears:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method main cannot be declared static; static methods can only be declared in a static or top level type

at server.SimpleChatServer$ClientHandler.main(SimpleChatServer.java:40)
 
lowercase baba
Posts: 12871
62
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wrote 200ish lines of code before you tried compiling?

that's your problem right there. Never write more than 2-3 lines before you compile. If you do, you are dooming yourself to failure.
 
Paul Clapham
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That message says that your "public static void main" method shouldn't be inside that nested class. Move it out of there so that it's a method of SimpleChatServer.
 
Moe Kennedy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:That message says that your "public static void main" method shouldn't be inside that nested class. Move it out of there so that it's a method of SimpleChatServer.



Thank you :thumbup:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic