Bor Kev

Greenhorn
+ Follow
since Jun 10, 2013
Cows and Likes
Cows
Total received
1
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 Bor Kev

Hi,

I am trying to deploy a fairly straightforward jar file on wildfly and I get the following error message :






Note : Wildfly is up and running ( I launched it through the standalone command line).

classes used are pretty straightforward :







Any idea why I am getting the following error when I am trying to deploy a fairly straightforward EmployeeManagementServerApplication.jar file on wildfly please?







2 weeks ago
I am currently studying for the OCA exam. I just saw that question on on a mock exam.

Given:




The answer was Compilation fails because the implementing method doStuff() in class MultiInt must be marked public. I do not understand why. Could anyone please explain this to me ?


Hi All,

Just wondering, now that OCMJD is retiring and that the deadline to purchase the  Java SE 6 Developer Certified Master Assignment 1Z0-855 has passed : Is there anyone who bought it before the deadline and would like to sell it because he no longers want to take the exam ?

I am just asking because I was planning on taking it and just realized 2 weeks ago -when I finally got my company to pay for it- that it no longer exists.

Sincerely,

Borkev
Hi,

I am sorry to insist but I do not understand your response. Which getValue method are you talking about? Are you talking about getValueAt method from the ResultCodesTableModel class or some getvalue method from the ResultCodesTable?

As far as the Model/View Concept is concerned, this is my understanding for tables :

the Table Model contains the actual data. This is why my ResultCodesTableModel contains two critical attributes :

1-  Vector<TableColumnData> : a vector (or collection) containing the table column names

2- Vector<T> : a vector (or collection) containing the actual data

In my case for testing purposes,  I hard coded the Table Model so that it actually contains all table columns names and the actual data.

Each row in my table will be a ResultCodesData :

Hence the code below :




The View for tables is taken care of by the JTable class, this is why my ResultCodesTable (which extends JTable) is as follows :



I have looked at many posts on forums and it looks like usually when there is a rendering issue - which in my case is a JCombox rendering issue - people should override the getCellRenderer method which I attempted but it does not work. This is why I do not understand what getValue method you are talking about. Could you please be more specific? there is no getValue method in the JTable class to override and there is getValueAt method in the table Model. If you are talking about the latter I do not know how to adjust it to reflect my actual data on the View (i.e when my Jtable is supposed to render my actual model). Thanks for your help.

Sincerely,

bor_kev






3 years ago
Dear Manesh Godbole,

Thanks for your reply the other day regarding how to render JCombo boxes in table cells.
I am facing a similar problem right now and although I am tweeking the Renderer in my code as much as I can I cannot seem to get around it. That is why I was wondering if you could have a look at my code and help me out please. So basically all I am seeing in the table display is the references to my comboboxes such as : RulesParameterJComboBox[,0,0,0x0,invalid,layout=com.sun.java.com.sun.java.swing.plaf.windows ..........


Her is the code for the domain class  :ResultCodesData



There is the code for : ResultCodesTableColumn

Please keep in mind that  RulesParameterJComboBox extends class JCombobox



code for the TableModel :



code for Table class




Also for some reason, I cannot select the cells individually , all I can select are the rows. Hope it helps.

Sincerely,

Bor_kev
3 years ago
Dear Manesh Godbole,

Thank you so much for your post. It worked !!

Sincerely,

bor_kev
3 years ago
Hi all,

I am supposed to create a table and all components of the second column are combo boxes. When I click on the combo box cells I can access the combo boxes drop down menu fine. However , there is no way for the user to know that the cells are combo boxes unless they click on the corresponding cells. Below my code. Any suggestions? Thanks for your help.

3 years ago
Dear Paul Clapham,

They actually suggest in the tutorial to compile all three classes (i.e Client.java, Server.java and Hello.java ) on the same machine. However, I do not understand the point. I thought the point of RMI was to be able to have remote objects being requested from a different JVM. This is why I am trying to have Client.java on a different JVM requesting remote objects from Server.java and Hello.java on a different machine. I am new to the concept so I apologize if this does not make sense for more experienced programmers.
Any ideas on how to fix this other than having all three classes compiled on the same machine please?

Sincerely,

borkev
Hi,

I am trying to run the basic Hellow World example discussed at https://docs.oracle.com/javase/8/docs/technotes/guides/rmi/hello/hello-world.html.

My point is to run it on two different machines with two different JVM . Both computers (Machine A and Machine B) have Windows 10 operating system and run Java 8. I compiled and ran the Hello.java and Server.java on Machine B. Everything went fine and perfect and I could even start the Java RMI registry and the server on that same machine. Everything happened smoothly as described in the tutorial.

However, problems started when I tried to compile Client.java on Machine A. When I tried to compile Client.java on Machine A, the compiler says "error cannot find symbol Hello". Any ideas how I could fix this please?

Below the source code :

Interface Hello on Machine B



Class Server on Machine B



Class Client on Machine A



Sincerely,

borkev
Dear Paul Clapham,

I apologize because I used the wrong terminology. As you mentioned, ReservationsManager and DvdFileAccess are top level classes, which stand on their own and they are not inner classes. I know that. Indeed, I was referring to the fact that Database has a static variable of type ReservationsManager and DvdFileAccess. I am perfectly aware that this is common practice. However, in the context of preparing for the OCMJD certification, I need to understand the ins and out of methods created by the authors as opposed to understand the implementation of methods that belong to the Java API libraries (i.e such as the String class as you mentioned). It is very important for me to understand so that when I get to create my own classes I can undertsand the subtleties. So, my question is not whether or not it is a perfectly normal thing to do or not (which I know it is) but rather :

If the member class ReservationsManager and DvdFileAccess are already mentioned as static members in the DvdDatabase class, do we really need to mention ReservationsManager member classes and DvdFileAccess member classes static again ( I am talking about private static Map<String, DvdDatabase> reservations, private static Lock lock, private static Condition lockReleased for class ReservationsManager and private static Map<String, Long> recordNumbers, private static ReadWriteLock recordNumbersLock, private static String emptyRecordString, private static String dbPath for class DvdFileAccess) ? Isn't it redundant ( I am not a java expert, that's why I am asking) ? Shouldn't they all just be private only with no static attribute? If not, which members should remain static ?

Note : I sent an email to the authors (Andrew Monkhouse & Terry Camerlengo) through the book's editor company but I haven't received an answer yet. I also understand that the book was published on December 15, 2005 (i.e more than 10 years ago) so I totally understand that the authors have moved on and are busy with other projects. That's why I am reaching out to the Java community. The book is excellent by the way and I learnt a lot from it. I don't mean to expose potential flaws , I just want to understand better. I strongly recommend the book for those preparing for OCMJD certification.
Sincerely,

borkev
Hi,

I am preparaing for the OCMJD exam and I read Andrew Monkhouse and Terry Camerlengo's book (SCJD Exam with J2SE 5 platform second edition) . I read and run their source code and I have a few questions that I'd like you to answer please. Source code follows.

1- why do they call getDvdList(true); in DvdFileAccess constructor if (database == null)? I mean if (database == null), then the physical database is empty, so we cannot get any DVD list basically. Therefore, we cannot populate recordNumbers (i.e Contains an index for our primary key (UPC number) to file location.) either. This is so confusing that I feel like I must be missing something. Any thoughts?

2- I tested the DvdDatabase setDatabaseLocked(true) method (which should lock the database) in my Main method as follows.



Well I don't understand why I was able to add a second DVD after locking the database. I was expecting an exception. How can change the source code to really lock the database and avoid this.

3- If I create 3 DvdDatabase clients in my main method, I will never be able to test the ReadWriteLock mechanism because they are not Thread classes right? so how do I test the locking mechanism?

4- I am not comfortable with ReadWriteLock, Lock,Condition classes ? Do we have to use those at the professional level or can we stick with the basics (i.e Threads, synchronized methods, wait , sleep , notifyAll) and do exactly the same thing and meet the professional standard?

Below the source code for the relevant classes :








Thanks for your help.

Sincerely,

borkev
Hi,

I am preparaing for the OCMJD exam and I read Andrew Monkhouse and Terry Camerlengo's book (SCJD Exam with J2SE 5 platform second edition) . I read and run their source code and I have a few questions that I'd like you to answer please. Source code follows.

1- If the member class ReservationsManager and DvdFileAccess are already declared as static in the DvdDatabase class, do we really need to declare ReservationsManager member classes and DvdFileAccess member classes static again ( I am talking about private static Map<String, DvdDatabase> reservations, private static Lock lock, private static Condition lockReleased for class ReservationsManager and private static Map<String, Long> recordNumbers, private static ReadWriteLock recordNumbersLock, private static String emptyRecordString, private static String dbPath for class DvdFileAccess) ? Isn't it redundant ( I am not a java expert, that's why I am asking) ? Shouldn't they all just be private only with no static attribute? If not, which member should remain static ?

Below the source code for the Database class as it appears in the book's source code :



Below the source code for the ReservationsManager class as it appears in the book's source code :



Below the source code for the DvdFileAccess class as it appears in the book's source code :



Thanks for your help.

Sincerely,

borkev
Hi Carey Brown Salil Wadnerkar,

Thanks for taking the time. I had already looked and read many tutorials and had come out by myself with "Harry Potter" as the regex query. The thing is I was doing Unit testing on the find method using the code below :



As the test was failing, I assumed that the regex query "Harry Potter" I was using was wrong. After a little thinking, I realized dvdDatabase.findDVD("Harry Potter") returns a Collection and not a DVD and that is why my unit test was failing and not because the query "Harry Potter" was wrong. Actually the "Harry Potter" regex query was good because when I tested assertEquals(1,(dvdDatabase.findDVD("Harry Potter")).size()) the test went fine.
Again sorry for the confusion.

Sincerely,

borkev


4 years ago
Hi All,

Given the following code :



What regex query should I write as a parameter if I want to look for and find all DVDs with the String "Harry Potter"?

Sincerely,

borkev
4 years ago
Hi K. Tsang,

Actually, I found out why I couldn't persist the file on disk : I wasn't using the right constructor. RandomAccessFile provides two constructors and I was using the wrong one :

public RandomAccessFile(File file,String mode) throws FileNotFoundException is the one I should have used to persist a file on disk. It creates a random access file stream to read from, and optionally to write to, the file specified by the File argument


Instead I was using :

RandomAccessFile(String name, String mode) which creates a random access file stream to read from, and optionally to write to, a file with the specified name. This constructor implies that the file -which string name is passed as a parameter- already exists.

Sincerely,

Maurice
4 years ago