Jo Jake

Greenhorn
+ Follow
since Apr 14, 2012
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
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jo Jake

I am new to Java as well as rmi. While running a test code I end up with exceptions and couldn't make it work. All I had is just a hello message from server. I get the java.rmi.NotBoundException when I call Naming.lookup I tried with different values for lookup url such as rmi://127.0.0.1/serviceA, rmi://localhost/serviceA etc ..but nothing did worked for me. Anyone please could help me to get this working.

Here is my server code :





And this server code compiles and runs without any issues.

Client code :



The client code compiles without any issues, and on running give the following :
The stack trace of exception :

java.rmi.NotBoundException: serviceA
at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:134)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:101)
at rmiclient.main(rmiclient.java:16)
Exception in thread "main" java.lang.NullPointerException
at rmiclient.main(rmiclient.java:21)



Thanks for any effort, probably many might have experienced the same I hope.
11 years ago
Good to see you Jesus, you gave me an inspiration as you were much like me in the way starting with Java. I am also looking forward to build such a career and to take all such certifications in future.
11 years ago
Thanks You Jesus for giving me a good picture on various Java technologies.
11 years ago
Actually I was looking for technology change from PHP to Java. (I'm more than 3 years experienced in PHP based web development) I would like to ascend in my career but with PHP I don't see any big firms using it in large scale, so the opportunity to go higher levels and higher salary for PHP seems lesser). But, I would have to know learning which technology in Java would be more time consuming in advance because if moving towards web development and to get hired for the same requires knowledge of jsp,jsf,frameworks,ejb etc and more (I don't know what all comes in Java web), then which requires too much of time isn't ? I thought if Core Java development requires less time to study, then I could try for a Job related with Core Java development. I already done learning Core Java from HeadFirst Java book. Now, in a stage thinking which thing to learn immediate next so as to get Job opportunity in Java.

With the help of other experts who posted comments here before explained me that learning JDBC is a must because its used in both Core Java development as well as Web app development. Also please see my previous comment :

Jo Jake wrote:I was very new to Java, then in few weeks time I have just finished now learning core java using HeadFirst Java book. But I didn't covered the topics on GUI - (swing,awt) . Now, I would like to know your suggestions regarding which is the easiest part to learn next in Java - Is that GUI topics like swing, awt so that I would be directing towards Desktop applications (right ?). Or is it easier to learn j2EE (jsp, servlets, ejb, jsf, frameworks like spring etc). I don't know anything other than core java topics I just learned. Though I had more than 3 years of PHP based web development, I thought to shift into Java due to some reasons! But I would like to know which part of Java is easier to start learning - Desktop app or web app ? As far as I come to know, it seems a lot of time and involvement is required to work on web side as I hear a lot of complexities in here such as EJB, JSF, frameworks, etc.

Also, please let me know what all do we have in Java to deal with database Or what we should learn to wire java app with database. Is that same for web development as well as desktop app ?

Thanks so much in advance to any and all advices I get from this forum.

11 years ago
Thanks Jesus & Campbell for quick response. If I am right JDBC would be usable on Desktop apps and Web apps, isn't ?
Also can somebody help me to understand where does other Java terminologies comes into role for example like EJB, JSF etc. ( Web apps, Desktop app, Core Java ?)
As am very new to Java, I request you experts to give me a brief idea on which Java terminologies is dealing with which stuffs. So that I would get a direction and path for learning, also an idea on which technology of Java deals with what. I do really appreciate and thankful for your time and efforts.

11 years ago
I was very new to Java, then in few weeks time I have just finished now learning core java using HeadFirst Java book. But I didn't covered the topics on GUI - (swing,awt) . Now, I would like to know your suggestions regarding which is the easiest part to learn next in Java - Is that GUI topics like swing, awt so that I would be directing towards Desktop applications (right ?). Or is it easier to learn j2EE (jsp, servlets, ejb, jsf, frameworks like spring etc). I don't know anything other than core java topics I just learned. Though I had more than 3 years of PHP based web development, I thought to shift into Java due to some reasons! But I would like to know which part of Java is easier to start learning - Desktop app or web app ? As far as I come to know, it seems a lot of time and involvement is required to work on web side as I hear a lot of complexities in here such as EJB, JSF, frameworks, etc.

Also, please let me know what all do we have in Java to deal with database Or what we should learn to wire java app with database. Is that same for web development as well as desktop app ?

Thanks so much in advance to any and all advices I get from this forum.
11 years ago
Thanks very much Martin. You have helped me in learning many things. And your example on Comparator with anonymous inner class and final String variable was so much helpful for me because I didn't knew before these points.
11 years ago
Thanks Martin for taking time to make such long explanations and advices. I liked the idea of Maps, it could easily deal with this situation but I would like to know further with the ArrayList case just only because I'm in a learning stage now. Please reply to my comments below :

Martin Vajsar wrote:
You will certainly not be able to make this using a single list and binary search. The binary search needs the items to be sorted by the criteria you use to perform the search, and with different comparators, these orders would be different.



In my implementation I do sorting with corresponding Comparator before performing binarySearch with the same Comparator for each of my search functions in the class MovieInfoManipulator. So there won't be the issue of orders getting different and resulting in wrong output. For example the search function searchByMovieName below does sorting first with movieNameComparator before performing binarySearch with same Comparator.



But, still I was wondering how to send String searchKeyword as second argument to binarySearch method when it expects movie object ? I think that is not practically doable right ? Probably binarySearch could be preferred only if I have ArrayList of Strings and then I have a searchKeyword string ??

Regarding filters that you mentioned, you mean to make a custom filter function isn't (Or is there any Core Java Classes supporting filtering this kind ) ? The custom filter function is supposed to search through the list of objects through a for loop and finds all objects that contains the searched value in each object's field values right ?.
11 years ago
Thanks Martin Vajsar. You really gave me an insight to the issue, but then I thought If I have multiple options to search such as search movies by Director, genre, rating etc. then I would have to create different maps for each movie property with that property as map's key right. I thought Comparator class could help here like the following :


etc ..

May be all the Comparator classes could be made also as inner classes to My MovieInfoManipulator Class. Any idea to implement such a model through Comparator though I don't know whether this model is good in performance than making a Map as you told ( for each Movie property - name, genre, rating...). What is your kind opinion ? Thanks for all the inputs that you all give me.
11 years ago
Thanks so much Campbell Ritchie for the reply and API link, but I couldn't figure out the issue because I had the Movie class implementing Comparable interface, and compareTo method as quoted below which compares the movieName attribute between different Movie objects. What I just need is to do binarySearch upon ArrayList of Movie objects where the search keyword would be movie name.



But when I write the following function searchByMovieName in another class named MovieInfoManipulator, where I have the binarySearch as
return Collections.binarySearch(moviesList, searchKeyword); : it gives the following compilation error "The method binarySearch(List<? extends Comparable<? super T>>, T) in the type Collections is not applicable for the arguments (ArrayList<Movie>, String)".

I think the reason is type mismatch between the ArrayList (list of Movie objects) and searchKeyword(which is of type String). But, then how do I pass the keyword ?? Please help me out in this. Very much pleased if I get to know the reason or if I can see a working example with similar case or atleast link to some other sites where I see a sample of similar case.. Thanks again.



public class MovieInfoManipulator {
ArrayList<Movie> moviesList;

public int searchByMovieName(ArrayList<Movie> moviesList,
String searchKeyword) {
// sorting before searching
Collections.sort(moviesList);
// binary search
return Collections.binarySearch(moviesList, searchKeyword);
}

11 years ago
Oh I got my mistake. Actually here I sent the wrong second argument on the binarySearch method:
moviesList : ArrayList of movie objects
searchKeyword : String keyword to search for in the ArrayList. I should have passed Movie Object as the second argument instead of searchKeyword string, right ? But, how to pass a Movie object when my intention is to just send a search keyword. So, I think this model doesn't works with binarySearch method. Instead, I should iterate the ArrayList and check each Movie object's name against the search Keyword using some equals method or something. Is there any other efficient methods possible ? As I'm very new to Java I haven't been exposed to such situations. I hope to learn much from the kind repliers on this topic. Thanks !

public int searchByMovieName(ArrayList<Movie> moviesList,
String searchKeyword) {
// sorting before searching
Collections.sort(moviesList);
// binary search
return Collections.binarySearch(moviesList, searchKeyword);
}

11 years ago
Or isn't it possible to implement binarySearch for ArrayList of custom objects ? Am I on the wrong track ?
11 years ago
I'm doubted regarding the implementation of Collections.binarySearch() method on an ArrayList of objects of a custom class Movie.

Here is the movie class :





Now, I have another class to manipulate the Movie objects as :




The sort/binarySearch in searchByMovieName function is done with natural sorting (and Comparable Interface in Movie class). I mean no comparators involved here. And the comparator that I used for sorting/binarySearching on Movies Director attribute in searchByMovieDirector function is :


.......................

But I was not able to implement binarySearch ?? Could anyone please help me out in how to implement the binarySearch here. I have google to see only binarySearch working on Arrays or probably ArrayList of String only, but not on ArrayList of custom objects. Thanks so much in advance.
11 years ago

chris webster wrote: ..or find a new job that might expose you to Java while you are learning?



Yes that sounds to be a more safe strategy, and I should try something likely. Thanks webster.
11 years ago