This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IOException error  RSS feed

 
Anton Lindroth
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am trying to make a small server and client program in java. I have this code:

Server:


And the client code:


Both is giving me a error like:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Client.main(Client.java:9)
sorry for my bad english and that I programming in Swedish
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your code, "args[0]" means the first element in the "args" array. And the "args" array, because it is the parameter of your "main" method, is the array of parameters which you typed at the command line after the class name.

So the error message says that you didn't type any parameters at the command line. Try again, this time including the parameter.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!