Zo Ve

Greenhorn
+ Follow
since Jan 31, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Zo Ve

Nice example with learning of language and dictionary.

I was thinking that I am doing something wrong while I am reading API documentation, and because of that, i don't see connection between some things. I thought that I have to jump into some entry point of some package, and from there I'll be sent where I have to go, depending of what I need. But I have to have some basic knowledge from tutorial to see that connection.
Ok, thanks people, that would be all for now.
See you on some other topic, with new question (probably about concurrency, that is next topic I am going to study after File I/0).
11 years ago
@Jasper
Actually I do.
There is one more problem for me that I noticed. Here is description:
When I read oracle tutorial about File I/O, they say that java.nio.file.Path interface is entry point for java.nio.file package. After that, i go in API documentation to see description for that interface. In description they don't say how can you get objects on which you can use methods of that interface.
See it, in tutorial they say that you have to create those objects from Paths class, but in API doc. they don't mention that at all.
So what I have to do? To read description for all classes in package java.nio.file just to get idea which class should I use, to get those objects, on which I can use methods from Path interface? Is there an easier way to do that?
Why is something called entry point if I have to visit something else before, to get to that entry point?

Let me clear this little bit more:
If i first go in API doc. to interface Path, nothing in that description suggests that I should use class Paths to create necessary objects.
But if I first go in API doc. to class Paths, I can figure out from method get(...) that i should go next to the Path interface.
How can i figure out, what is first place that i have to visit in API doc, when I start to study some package, to get idea where to go to the next place?
11 years ago
Some things are clearer, some are not. But this conversation was useful for me.
Ok people, thanks to you all, on your time and your patience.
11 years ago
@Jasper
This discussion went too wide.
Things about classes, objects and so on are not problem.
I used term "object of type Path", because of shorter conversation, not because i believe that I can instantiate object from interface. Consider that term as you wrote "object that is an instance of a class that implements interface Path".

I have to return to the beginning. Problem is following:
When I see in API documentation some interface, first thing that comes to my mind is that i have to write class with all implementation of interface methods. But in case of, for example Path interface, those implementations are already written for me. So how can i know for which interface those implementations are written and and for which interface they are not, reading just API documentation.

Or maybe, you want to say that for all interfaces in API doc, implementations of their methods are already written, excluding those specific interfaces for EventHandling (like ActionListener)?
11 years ago
Sorry people, i know that I am annoying with my question, but i need this conversation, because i have feeling that i have missed something, when i tried to learn interfaces.
11 years ago
@Steve

If you gave me an interface, and nothing else, then I would have no indication that the interface has been implemented. If you gave me an interface and a class which returned an object with the type of your interface, then I would know that there is an implementation in your code somewhere. If you don't make that implementation coderanch, then you are telling me that I don't need to know about it, I should just use the method's return value.



Using this criteria, how would you treat interface Path?
When you go in API documentation, class Paths (whose method returns object of type Path) isn't mentioned at all in description of Path interface.
So if i haven't gone through tutorial i wouldn't see any connection between Path and Paths?
In tutorial they say that interface Path is one of the entry points for package java.nio.file, but when i go in API documentation, nothing suggests in description that i have to go first in class Paths, if I want to get objects of type Path.
11 years ago
@Jasper
...it will do nothing...
instead of
...it want do nothing...

(error in my comment)
11 years ago
Jesper I think that I have understood much of what you've written. But let me ask you new question.
Lets say that you see for the first time interfaces: java.awt.event.ActionListener and java.nio.file.Path.
Both of that interfaces have they own methods. But usually i have always to write my own implementation for method actionPerformed() in interface ActionListener. In case of Path interface, you can use those methods as you wish (don't need to implement them if you're satisfied with their implementation). If I use method actionPerformed() as they gave us, it want do nothing, but in case of Path methods, all the methods do something.
So, how do you know in which interface you have to implement methods, and in which interface you don't. Does it come from experience, or I have something missed to learn about interfaces?
11 years ago
Ok Paul, that sounds like reasonable explanation. I didn't know before for non-public classes.
Problem that I think exists is following:
Suppose i write some interface with some methods and i document it in some API doc. And I give that interface to you to use it. You will not know that methods of my interface are implemented somewhere or not. So you have to test it with some peace of code. It would be easier that somewhere is written: "methods of this interface are already implemented, you can overwrite them if you're not satisfied with our implementation" or "methods of this interface are not implemented, you have to implement them yourself".
I think that i see flaw in documentation, but i am not sure. I don't know Java that good, so I have dilemma, am I asking a stupid question or there is flaw for real... or thing is totally irrelevant, but i can't yet figure out that with my knowledge of Java.
11 years ago
@Jesper de Jong
You wrote:

All the methods that are available on interface Path are implemented, so you can call them as you like.


How do you know from API doc. that they are implemented?
(ok, i know that they are implemented somewhere, as far as i can use them, but how can i know that from API doc).
11 years ago
@Emil Jennings
If you go in API documentation, and look on interface that i used in my example: java.nio.file.Path, there is not section like: All Known Implementing Classes.
But methods of interface Path are somewhere implemented, so I can use them. I don't see that class from API documentation, that implements those methods?
11 years ago
I am currently learning Orace Java tutorial , about basic I/O.

There is example:



Problem that i am facing with is when i look description, in API documentation, of some interface, how can i know that methods of that interface are already implemented, so i can freely use them, without implementing them by myself?

In this peace of code that i posted, there is interface Path, when i look description for that interface there are lot of methods, one of them is toUri(). How can i know from API documentation, that those methods are already implemented somewhere? And where are they implemented at all, in which class?
11 years ago
Ok, it works.
But only when I set up classpath like this:
javac -classpath "C:\Program Files\mysql-connector-java-5.1.14\mysql-connector-java-5.1.14-bin.jar;." Connect.java
And when I execute program I need to use this:
java -classpath "C:\Program Files\mysql-connector-java-5.1.14\mysql-connector-java-5.1.14-bin.jar;." Connect


Case when I set up classpath like this:
set CLASSPATH="C:\Program Files\mysql-connector-java-5.1.14\mysql-connector-java-5.1.14-bin.jar";.
still doesn't work.

Thanks people, you hellped me a lot of with this, now I can move forward.
Ok, I changed that line of code. This is output:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at Connect.main(Connect.java:14)
I changed CLASSPATH in this way:

set CLASSPATH="C:\Program Files\mysql-connector-java-5.1.14\mysql-connector-java-5.1.14-bin.jar;."
( I added a . after ; I guess this is correct? )

But now i get this output:

Cannot connect to database server