Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Jose Lara

+ Follow
since Apr 17, 2016
Jose likes ...
Android Oracle Java
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jose Lara

Paul Clapham wrote:

Jose Lara wrote:My problem is how I access to that specific animal just clicking in the JTree? It should be something like:

I suppose you haven't read the JTree tutorial so you should put aside your code and spend some time doing that. So much of what you are doing there is just the wrong way to do things in Swing.

You should never use MouseListeners unless you really have to. Swing almost always has more convenient tools than that. If you want to get the data from the tree node when you click on it, then you just use a TreeSelectionListener. That's near the beginning of the tutorial. And once you have got the selected node, it should already contain an Animal object. Make sure your Animal class has a suitable toString() method because that is what Swing uses to display an Animal on the screen.

And your idea of refreshing the tree every time you change something in that list is hard to understand too. For one thing you didn't say how you were changing the list -- wouldn't it be easier to update the tree directly? Seems like you're letting your code force the design rather than having the design tell you what code to write.

Hello Paul. I will check about the TreeSelectionListener and hopefully it will work.

About just refreshing the tree everytime I change something, I tried but for some reason it was not updating properly. When I deleted some object, it was not deleted from the node after refreshing. For sure I was doing something wrong, but after fighting a lot with that, finally I decided to take this not so good solution. As I said before, this is the first time I am working with these things.

Thank you so much for your answer.

Best regards.
5 years ago
Hello guys,

The other day I was asking a doubt about a database and today I am coming with another one. I am really sorry to ask so much, but lately I am writting a lot of code and "playing" with new features that I have not used before.

I am having issues accessing the elements of my ArrayList just clicking in the corresponding node. This is the first time I am using the JTree, I have searched for a lot of different tutorials but I could not solve my issue. I will explain you what I have:

class Animal: Just constructor with different arguments, setters and getters.
class MainClass: ArrayList of animal. Main is running here.
class Menu: JFrame designed with NetBeans. To get the elements of the ArrayList I use the next code:

Everytime that I add or remove an element from the ArrayList, I use refreshTree() method in order to get an updated version of my ArrayList.

In my Menu class I have also different JTextPanel for the different attributes of the animals.

What I need to do (I will not copy the code I have right now, because I think has not sense) is to be able to click in one node, so the different attributes of the animal are loaded in the JTextPanel, so if I modify the values, they will be changed in the object as well.

I know I should use something like:

And then use the setters of my class Animal.

My problem is how I access to that specific animal just clicking in the JTree? It should be something like:

Thank you so much in advance.

Best regards.
5 years ago

Ron McLeod wrote:Well .. I just tried your code and I didn't get a I did however get a, which is expected because your code treats EOF as an error, rather than an indication that there is nothing more to be read. readObject only returns a null if the obecj read was a null, it does not indicate end of objects.

I added a println so that I could see each object as it was being read.

Name: A&W/lnCity: Richmond/lnPostcode: V6Y3C6/lnAddress: 12203 Garden City Road/ln
Not possible to add the Restaurant
   at$BlockDataInputStream.peekByte(Unknown Source)
   at Source)
   at Source)
   at com.joselaraproductions.RestaurantService.loadRestaurantList(
   at com.joselaraproductions.UserController.<init>(
   at com.joselaraproductions.Tester.main(

Thanks Ron! I am going to double-check the code!
5 years ago

Salil Wadnerkar wrote:The offending instance variable may be: private ArrayList<Menu> menus;
Is your Menu class serializable?

Yes, same thing:

I just eliminated the System.exit(0) from the exceptions and even if I am getting the same issue, I think that is working fine =/

Anyway, I would like to solve it in order to work properly without throwing exceptions!

Thanks again!
5 years ago

Ron McLeod wrote:

Jose Lara wrote:Yes, all the classes implements Serializable, so I don't understand from where this error is coming =/

As Salil suggested -- have you checked that the fields which are instances of other classes are also Serializable (or marked as transient)?

Do you have any inner classes?

No, I don't have any inner class.

I am not sure which ones I should mark as transient =/ I post the code of the Restaurant class for Salil, let me know if I should post of another class.

Salil Wadnerkar wrote:Can you post the code for com.joselaraproductions.Restaurant ?


Norm Radder wrote:Can you make a small, simple program that compiles, executes and shows the problem?

Sure! I will try it and post it here. That's a good idea to make it simpler!

5 years ago

Salil Wadnerkar wrote:...

Norm Radder wrote:...

Yes, all the classes implements Serializable, so I don't understand from where this error is coming =/
5 years ago
Hello guys,

One last question and hopefully will be the last one.

Finally I have my database working almost totally fine. The only problem I am having is about saving the information and loading it. For that purpose I am using serialization (or trying at least).

In my RestaurantService file (for the management of the restaurant objects in which is based the database) I have the next two methods for saving and loading the file with the information:

And in my UserController class:

Both classes implements Serialializable, but when I am running I get the next error:

I don't know what is going on. Someone knows what could be happening?

Thank you in advance.

Best regards.

Jose Lara.
5 years ago

Norm Radder wrote:

java.lang.ClassNotFoundException: spark.Request

That looks like the class was specified to be in the spark package. Is the Request.class file in the spark folder in the jar file?
What is in the manifest file for Main-Class?

Salil Wadnerkar wrote:When you add libraries in Netbeans IDE by using "add libraries", maven does not know about that dependency. So, even though you can build and execute the project using Netbeans, you are having problems running the jar outside the IDE. Since all IDEs support maven projects, I think you should remove all dependencies you added using Netbeans menu and explicitly declare these dependencies in maven's POM. If the project builds using "mvn package", that means you have declared all dependencies to maven correctly.
Now, maven will create the jar correctly. However, it is not an executable jar. So, when you try to run jar using "java -jar <jar-name>", you get the manifest error. So, you should use maven-jar-plugin to create an executable jar. And if you don't want to specify the libraries (spark and other libraries) on the classpath, you should create an executable "uberjar" - so that all dependencies are packed inside one jar.

Thank you to both of you!

It was exactly as Salil said. I just "installed" Maven in my laptop and was able to build the project using "mvn package"

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.505 s
[INFO] Finished at: 2016-06-06T12:54:35+01:00
[INFO] Final Memory: 19M/142M
[INFO] ------------------------------------------------------------------------
5 years ago
Hello everybody,

This is the first time I am working with frameworks from Java, so I have a lot of doubts in general.

I have to create an API of a database able to run both on iOS and Android. I have created databases before using the Collections, but I have never designed APIs before, so this is quite a new world for me.

For this purpose I followed the next tutorial, that explains how to create a RESTfull API using Spark (

I just created my own database, quite more complex than this one and I tested in my localhost using Postman. Until this point everything is working. But my problem begins here, as I am quite lost about all this stuff.

I read that in the case of smartphones, it is necessary to execute the .jar, so I tried to do it first from my laptop but I got the next error: Can't execute jar- file: “no main manifest attribute”.

I extracted the .jar file and checked that the MANIFEST does not include the line "Main-Class: MainClass", so I investigated and found this:

I added the mentioned lines in my POM file, as it is for Maven, but now I am receiving some new errors when trying to execute the .jar

Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: spark/Request
at com.joselaraproductions.UserController.<init>(
at com.joselaraproductions.MainClass.main(
Caused by: java.lang.NoClassDefFoundError: spark/Request
... 2 more
Caused by: java.lang.ClassNotFoundException: spark.Request
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 2 more

Can someone help me? Because I am quite blocked right now and I have been a full day with this.

I also accept some tips, good documentation if you know (with screenshots and so on, not like the official one, that is really complicated for newbies) and whatever thing that could help me with this or future problems.

PS: I use NetBeans in the case that I should add PATHS, change properties or whatever.

Thank you so much for the help.

Best regards.

Jose Lara.
5 years ago

Henry Wong wrote:

Jose Lara wrote:
This is a shared project with one friend who obviously does not share my LAN. Can someone give me ideas about what is the best way to work together? Is there any way for my friend to access somehow my local server?

There are quite a few tools that can be used for collaboration -- such as webex, or gotomeeting, etc. These tools allow for switching presentation hosts, or even who controls the hosts.


Hello Henry,

What I need is some way for being sharing the same "web site" that we are creating without paying for a domain and have it online.

Basically, I can connect to my computer, go to "localhost/my_project" in the browser and access to our project and the same for him. Is it possible? I know it is possible in the same LAN.
6 years ago
Hello guys,

I have just begun with web development recently, so I am still quite lost. The thing is that I installed Wamp in my computer and I am using the WordPress CMS for creating a website.

This is a shared project with one friend who obviously does not share my LAN. Can someone give me ideas about what is the best way to work together? Is there any way for my friend to access somehow my local server?

Thank you so much in advance.

Best regards!
6 years ago
Thanks again Roel!

My ex-manager was also from Belgium and he gave me some really nice beers from there. I definitely need to visit your country haha Anyway, I was living in Czech Republic, so it wasn't so bad as well ;)

I already added my information into the Wall of Fame.

I totally agree with you about using the text editor, but in my case it is a lot of years already using my dear NetBeans haha But of course, for a newcomer in programming/Java the best thing is avoid the IDEs at the beginning. In any case, even if the IDE is telling you what you need to correct in order to compile it, you can just try to run it and you will see what is actually happening.

About "what would happen if I try to pass a char instead of an int as reference in a method?" it was just an example about some thing that could come to your mind. Of course, there will not be any problem, but I feel useful "to play" with all these things. For example, let's say that we have 2 overloaded methods receiving a char and an int as arguments. Now you assign to a char a number value and try to call the overloaded method. These are for me the kind of things that people should try when coding.

Thanks for the cows! I don't know for what is that, but it looks nice to have already some animals in my virtual ranch haha

Best regards!
6 years ago
Hello Priyavrat,

You can actually go even for Java SE 5 and 6, Certified Associate 1Z0-850.

As K. Tsang said, which version you feel more comfortable with?

In my case I just decided to go for Java SE 7 because this is the version that I've been using last years and that I know his features and also because I was able to find more documentation than Java SE 8.

In a professional way I don't think it will be really relevant. I think that if you are able to get the SE 7, you would just need to study a bit to know the new features from the new version and that's all. I don't think a campany is going to care so much which version you have if you were already able to get the certificate. For example, I was working as a Network Engineer and I can tell you that companies didn't care so much if we have an expired CCNA/CCNP for example. If someone is able to get it, it means that is able to learn anything in a same level. I don't know if you will get my point...

In any case, good luck with your certificate =)

Best regards!
Hello everyone,

I recently got my OCAJP certificate and right now is time to search for a new job.

I have been working as Network Engineer at AT&T for 1 year and a half. I just left because I wanted to begin my professional career in the Java sector, as I already had experience coding and I believe that Software Development is more for me than Networking.

I write you for recommendations about companies that you know that are normally hiring new employees and you think are quite good. I don't care if it is just a Junior position or if I have to move (I currently live in Spain). The only thing is that I am interested to move only to English, Spanish or French language country (also German, even if I have to learn from zero).

This is my LinkedIn profile in the case that you need to check more about my experience/studies/skills:

I will appreciate all your suggestions or ideas.

Thanks you in advance.

Best regards.
6 years ago

Roel De Nijs wrote:

Jose Lara wrote:I did it! First attempt and 88%

Congratz! (I'll reserve the fancy congratulations for when you have shared your experiences )

Thanks Roel!

I just wrote another post with my personal "study guide". I hope it will help some people.

Best regards.