Skip to main content.
December 26th, 2008

The Book “Introduction to Programming with Java” is Finally Published

Intro Java Book - front cover

Recently my team of 20 authors and few editors working on creating a contemporary book about the fundamentals of computer programming, data structures and algorithms is ready with the public official release of the book: http://introjavabook.googlecode.com/files/Introduction-to-Programing-with-Java-Book-v1.01.pdf.

The book “Introduction to Programming with Java” focuses on the fundamentals of computer programming, logical, algorithmical thinking, problem solving, data structures and algorithms. It uses a contemporary object-oriented approach and language but is valuable for any non-Java programmer in the begginning of his career. The book is free and open-source.

The contents of the book:

  • Chapter 0. Preface
  • Chapter 1. Introduction to Programming
  • Chapter 2. Primitive Types and Variables
  • Chapter 3. Operators and Expressions
  • Chapter 4. Console Input and Output
  • Chapter 5. Conditional Statements
  • Chapter 6. Loops
  • Chapter 7. Arrays
  • Chapter 8. Numeral Systems
  • Chapter 9. Methods
  • Chapter 10. Recursion
  • Chapter 11. Creating and Using Objects
  • Chapter 12. Exceptions Handling
  • Chapter 13. Strings
  • Chapter 14. Defining Classes
  • Chapter 15. Text Files
  • Chapter 16. Linear Data Structures
  • Chapter 17. Trees and Graphs
  • Chapter 18. Dictionaries, Hash Tables and Sets
  • Chapter 19. Data Structures: Comparison and Best Practices
  • Chapter 20. Object-Oriented Programming Principles
  • Chapter 21. High-Quality Programming Code
  • Chapter 22. How to Solve Programming Tasks?
  • Chapter 23. Example Topic from Exam in NASD – 30.09.2005
  • Chapter 24. Example Topic from Exam in NASD – 8.04.2006
  • Chapter 25. Example Topic from Exam in NASD – 11.12.2005

More information is available on the book’s official Web site: http://www.introprogramming.info/.

Posted by nakov as news, java, blog at 3:36 PM EET

Comments Off

December 12th, 2008

JSObject.getMember() Hangs in Safari in Mac OS X Unless You Move the Mouse

Last few nights I was debugging very strange bug. Few months ago we shipped Java applet signing Web forms in the client’s Web browser. It was tested under IE 6, IE 7, Firefox 2, Firefox 3, Opera 9 and Safari 3 for Windows. We tested with Java 5 and Java 6 in Windows and Linux environment. We didn’t tested the applet in Mac OS X because we didn’t have Mac machine.

Few days ago our customer reported that the applet does not work in Safari and Firefox in Mac OS X. My nightmare started. First I needed to install and run Mac OS X in a virtual machine. It takes a lot of time, runs very slowly and networking is unstable but this is another story.

I found 2 great bugs when using JSObject to access the Web page DOM from java applet in Firefox 3 on Mac OS X and Safari 3 on Mac OS X.

JSObject.getMember() Always Returns Null in Firefox on Mac OS X

The first problem was with Firefox 3 on Mac OS X. When you call JSObject.getMember() to get some property from an object inside the Web page DOM, it always returns null. This method is not supported in Mac OS X and the only information you can find in Internet is that other developers have the same problem and there is no solution. This bug in not published and there is not fix. It just does not work.

The second bug was even more strange.

JSObject.getMember() Hangs in Safari in Mac OS X Unless You Move the Mouse

Sounds strange but this was the exact behaviour: in Safari 3 in Mac OS X 10.4.2 calling JSObject.getMember() blocks for unlimited time until you move the mouse over the applet. It was very strange. When you move the method call returns with the correct result. If you don’t move the mouse over the applet, it hangs for unlimited time. The first thing I did was to configure the JVM for remote debugging, to compile the applet with debug infor and to attach remote debugger form my desktop machine to debug the applet running inside the virtual machine. The strange behaviour was confirmed. Calls to JSObject.getMember() were henging until you move the mouse. I tried lots of ways to overcome this (e.g. adding synchronization, invoking the operations accessing DOM from the AWT dispatch thread and through the main applet thread). Nothing helped. 

I found in Internet that others have the same problem and have partial solution with running seperate thread. When I run separate thread for the job accessing the DOM tree, my problem was solved. Nice workaround and works for all browsers. I added additional code to prevent the job accessing the DOM tree to start several times in parallel. Finally, after few other fixes my applet for signing Web forms runs in Safari under Mac OS X.

For some reason the AWT dispatcher thread is put into sleep by Safari during the calls of JSObject.getMember() and moving the mouse wakes it up to process the mouse events inside the applet and that’s why it behaves strangely. I don’t have complete explaination why seperate thread works differently, but it works. Debugging applets’s threading issues was challengeable task but I hope this to be my last project for developing applets.

Posted by nakov as blog at 2:24 AM EET

Comments Off