Hari r.haran

Greenhorn
+ Follow
since Feb 01, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hari r.haran


Hi Mathew,

Well, it is possible for other program communication using java. But the thing is that the other application should be developed, such as to accept or provide replies to your java program. For example, If you take microsoft word, you can manipulate certain things automatically, using COM. Microsoft had developed it in such a way so that programmers can use it. I am not aware of msn messenger. You better check out the documentation of the application that you are going to communicate.

If an application accepts input from stdin and gives output through stdoutput, then you can use the Process and Runtime classes to create a process and then using the getInputStream() and getOutputStream() methods, you can communicate with the process.

Hope this helps.

Regards,
Hari
13 years ago

Can I tell you one more algorithm or you want to update yours?
13 years ago


At runtime, the JVM decides the object to call.

Regards,

Hari
13 years ago
Hi,

I understood the confusion that you have.

Well, those type of statements are allowed in Java. The first line



is a declaration, whereas



is initialization.

An interface is nothing but an 100% abstract class. During the declaration part, you are declaring an object that may contain any class that implements the interface. We used to tell that the classes or interface that have inheritance as their relationship, is having a "IS-A" relationship. For example, if I have a class named Bird, and if i inherit this class in "Pigeon" class, then we tell that "Pigeon is-a bird".

This will be useful in accessing a common method, that are present in all the subclasses. Again for example, if i have one more class in the above example, say, "Parrot", and if i want to call the fly() [assume we have it] method in both the classes, it is efficient to use a Bird class object [even if it is an interface], and store an instance of Parrot or Pigeon. At runtime, the JVM decides the object to invoke the method.

This is runtime polymorphism.
13 years ago
Do you don't even want to copy and paste the code?
13 years ago
Hi again,

If you want to use the NetBeans IDE, then just create a java project, and then create a new class file with whatever class name you want, inside the project.

Once you want to try executing a code, you simply copy paste the code in the source file which you have created now in the project. Definitely you will get an error stating that the class name is different from the file name. Since it is netbeans, it will show hints to the right hand side of the error line. Click on that yellow bulb to get a list of error-correction options.

Netbeans would show options for either correcting the class name or the file name. You simply click on the option that changes the file name. After that, you won't get any errors. You can simply do it for all the code you want to try.

Regards,

Hari
13 years ago

Hi,

If you don't want to use any IDE, then you could go for manual compilation and interpretation of the code. The following is the set of steps to do so.

1. Create a java file with some name like "Test.java" in java's home directory (Done only for the 1st time)

2. Copy paste the code in the file. If the class code you have, is public, then remove the public modifier in the class declaration and then save it.

3. Open cmd.exe and change to java's home directory. (Done only for the 1st time)

4. Compile using javac Test.java

5. Execute using java className

Afterwards, if you want to execute a new code, overwrite the existing code and save it. Cmd.exe saves all the commands that you type. So you could simply use the up arrow to compile. Only for executing you must just change the className to the new className in the example that you copied.

This might seem very tough, but once you try, it s the basic and the most easiest way.

Thanks and regards

Hari
13 years ago
Hi,

Could you please tell which IDE you use for running the source code?

Regards,

Hari
13 years ago
Try adding the following to your page so that the browser will not cache the page:

<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
13 years ago