I believe there is a plugin for Eclipse to code J2ME also.
peter_budo commented: What "great" idea to reopen 6 years old thread... -3
I believe there is a plugin for Eclipse to code J2ME also.
And for reference you can't make a .exe from source code you implement in java.
Only .jar and then you can use a 3rd party program to package it in .exe.
Yep that one is good also.Although, It doesn't mention Synchronization I don't think.
I think he means java software already made.
koti86, java software in windows, mac, all work on linux also.
Java is cross platform. That is usually one of the first things you learn when you start coding in Java ( The background/basic info about java ), maybe your teacher missed this part or you was not paying attention?
As for finding software, I haven't checked but did you try searching google for something like 'java software'?
Btw, Bill Gates didn't invent the computer. He invented The operating system Microsoft Windows on which he copied the source code of Steve Jobs Operating System and then added to it his own implementations/ideas.
The site is Javaworld and I highly doubt there is malware coming from there.
You realize your first 3 sentences are redundant right?
In your topic post saying you want to create an instant messenger program in java would have been enough.
Now with out the nit picking...
That would be the same as creating a chat program. Check out this tutorial and the book How to program by Dietel and Dietel has a a very good case study on this in chapter 24 ( networking ).
When you declare or define a method a method has a method signature which is the access modifier ( public, private, or non which makes it package level ), then you have a return type ( void or of some type such as String, Int ( integer ) , etc ) , then there is the name of the method that you create or want , next is the arguments that it takes that go in parenthesis.
So an example would be
public void changeColor()
That is called a method signature.
The body is every thing after the open bracket up to the closing bracket...
public void changeColor(){
//Body is here
//Statements go in body
}
A methods arguments that go inside the parenthesis is used for passing values and references around. Think of the methods arguments as an entrance for things (objects and primitive types).
public void changeColor(Color color){
//Do things with the color passed into this method
}
Some other method may invoke or call that method...
car.changeColor(red);
//Now the cars color will be red
Methods are used to do actions, behaviors, operations on objects.They can change the state of an object ( mutator methods ) or they can get/receive information from an object ( getters/Accessor methods );
I hope the short summary was what you were looking for and it helps.
I think you should do more reading, and studying.
Here is a tutorial on making a space invaders game...
http://www.cokeandcode.com/spaceinvaderstutorial
Moving could require either a Timer or a Thread.
You would also need a keylistener for key events if you want to move with the keyboard. Have you studied these classes yet?
thx javaAddict
I want to make a Planet ships protected by two spacecraft and shoot all the ship that want to get on the planetthis is the game
That is very ambiguous, or in other words you are not clear and explaining your self to well.
You should take the time to explain in good detail what is the game and how it is to be played out.
That will end up being your case study, your games walk through for what needs to happen. You can then use that to help you recode the game and we can give you some suggestions.
Also, we will be able to help you easier when we know how much experience you have in programming and java.
What have you gotten so far for your code?
You have the definition fundamentals down for what you need to do, now you can search the java api for that. Searching the API for tokenizing will bring you upon a StringTokenizer. However, you could read in the file with a buffered reader that takes an argument of file reader, which take an argumenet of a file. Then you can read in each line of the file/text by calling readLine() method on the buffered reader, and then you can even split each word by invoking the split() method on a string.
The split method can take an argument of a delimiter and returns an array with each word split with the given delimiter.
Then you can iterate through each word and do what you please with it.
I hope that all made sense to you. If not, I can elaborate.
First of all thanks for taking my problem seriously, and spending housr on it. If you have working code please paste it as till now I have not studied about writeUTF() function.
Do paste the complete working code , it will be helpful for me to learn some new more function etc.
writeUTF and readUTF is not that complicated, i didn't study it at all but I understand it's behavior.
If you want the code still then here it is, even has sound for when sending a message and a timestamp/clock for each message.
package Client;
/**
* File: ChatClient.java
* ChatClient represents a graphical user program that sends and receives messages to a chat server
* In order for the chat client to start sending and receiving messages, the user has to give a user name first.
* It listens for incoming messages from a server and when it has messages, displays it to the screen.
* @author Anthony Turner
*
*/
import java.io.*;
import java.net.*;
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.text.Document;
import java.awt.event.*;
import java.awt.*;
public class ChatClient extends JFrame implements Runnable, ItemListener, FileMenuConstants, ButtonNameConstants{
//Constant fields
private static final long serialVersionUID = 1L;
private static final int FRAME_WIDTH = 800;
private static final int FRAME_HEIGHT = 600;
//Instance fields
private JEditorPane displayArea;
private JTextField inputField;
private ChatClientHandler clientHandler = new ChatClientHandler();
private Socket socket; //Creates a connection to a server
private DataInputStream inputReader; //Reads in server socket data output
private DataOutputStream outputWriter;//Writes out client socket …
Yeah, I suppose it's fine for chat. I was thinking about some recent network-based client synchronization code I was working on when I wrote that.
SPeaking of synchronizing, that is also a good idea in the chat program....
private void broadcast(String message) {
synchronized (handlers) { //Sync all client handlers
Iterator<ClientHandler> it = handlers.iterator();//Get an iterator for each client handler
//Get each client handler
while( it.hasNext() ) {
ClientHandler handler = it.next();
try {
synchronized (handler.outputWriter) {
handler.outputWriter.writeUTF( message);
handler.outputWriter.flush();
}
}
catch(Exception e) {
handler.stop();
}
}
}
}
}
There is a nice article on java world about Building an Internet Chat system
Ye, somewhat you are true.
I am not getting anything on the text area, moreover on the server side I have put the code for printing the message to server on line no. 50 of server class. That's also not working,so check it out and if any more confusion be free to ask.if after changing the BufferedReader and PrintWriter class it works then please paste the code here..
Try changing to the data types I mentioned, and start your threads. I debugged and trouble shooted your code for a good amount of hours and soon as I changed the data types it worked right away.
I guess he could have said what he meant by "desired result".
If you mean that your desired result is nothing showing up on the text area then I have messed with this for awhile, and try changing all of your buffered reader and print writers in all classes to a DataInputStream and DataOutputStream. Then use the methods readUTF and writeUTF.
All good recommendations.
There is also a Stanford University course on Programming Methodology and they teach Java. The Lectures are actual class lectures of a professor teaching his students. From lecture 1 all the way through to about lecture 29 or some where around that. Each video is about 45 minutes in length. You can go to the site mentioned in the videos and download all the available documents except for the Karel learns Java and The Art of Science in Java by Eric Roberts books. If you search, you can find them on the net. Th Art of Science In Java is a preliminary version that is very good.
If you are really interested in learning Java, and are serious about it. I would check these videos out on you tube and follow the Syllabus, do the exercises, and read the assignments.
Or, if you want to allow for multiple circles, triangles, or whatnot, you might allow for the input of a parameter or two, to represent the dimensions of the geometrical object in question. For a circle, for example, you need an int or a double, depending on whether you're dealing in integers or decimals.
Your return type will probably not be an int, if you're dealing in circles - unless you want to truncate the area down to an integer value. (You don't want a unit circle with radius 3 - unless you're in Kansas, where it's the law!)
Good point.
So your code would look similiar to this...
//comments here
public double getArea(double radius){
//calculations for the area of a circle goes here
//then return it's value
}
You mean such as creating a method and returning a calculated radius?
your method signature/skeleton would look like this
//comments here
public int getArea(){
//calculations for the area of a circle goes here
//then return it's value
}
Hi all I'm having a bit of trouble wrapping my head around exactly what hiding a class method does, can somebody try giving it to me in plain English? I'm going by the Sun Java Tutorial but I find the example a bit vague when it comes to the hiding. I have no problem with overriding methods that seems simple enough I just can't wrap my head around why you would want to hide a class method in a subclass instead of creating a new method specific to the subclass.
If i understand what you are referring to correctly, then it all comes down to code reuse. Why create a new method when you already have one there. Plus if need be, you can add more functionality to the method. Like appending more data to the superclasses data already exsisting in that method.
Also, I believe Polymorphism has a good play on what you can do with overriding methods.
You can do this..
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
int MAX_DAYS = 7;//Number of max days in week
Days[][] Days_Period = new Days[MAX_DAYS][1];
int i = 0; //Counter for Days_Period array
for(Days day: Days.values()){//Get each day from enum starting with Monday
Days_Period[i][0] = day;
System.out.println(Days_Period[i][0]);//Test print the days after each add
i++;
}
}
}
As mentioned your code for Days in an array is not valid because Days is of type enum not of type String, so you use the .name method to return it as a string.
The way I illustrate it, for each enum value , it puts its value to an array on each iteration.
The type of the array is of type enum Days.
If you wanted strings you would have to change the type for the array to String and call a method on each enum value to get either it's name or a string representation of the enums value.
AKA parameterized types.