Difference: JavaNotes (19 vs. 20)

Revision 2016 Mar 2004 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="ProgrammingNotes"
Java is a popular programming language written by Sun Microsystems. It's an object-oriented language that runs inside a "virtual machine" which, at least in theory, allows code to run on many different machines. Sun calls this "Write once, run anywhere", and in practice it actually works reasonably well, although it took years for this to happen.
Changed:
<
<
Java is extremely popular in commercial software development - it's dominant in the area that I work in: operations support software for communications companies. It's not at all popular in the Free Software community because it's a proprietary product owned and controlled by Sun.
>
>
Java is extremely popular in commercial software development - it's dominant in the area that I work in: operations support software for communications companies. It's not that popular in the Free Software community because it's a proprietary product owned and controlled by Sun. There is a lot of "open source" development in Java, though.
 
Changed:
<
<
The Java home page is http://java.sun.com/; you can download a developer kit or run-time from there. Java per se is a proprietary product, but there are many free projects that aim to provide all (or part) of the Java environment as Free Software. http://www.dwheeler.com/java-imp.html lists many of those projects.
>
>
The Java home page is http://java.sun.com/; you can download a developer kit or run-time from there. If you're running on Linux and don't need the latest-and-greatest API then you can use the IBM JVM which I've found to be faster than Sun's: http://www6.software.ibm.com/dl/lxdk/lxdk-p

Java per se is a proprietary product, but there are many free projects that aim to provide all (or part) of the Java environment as Free Software. http://www.dwheeler.com/java-imp.html lists many of those projects.

  See also: JavaProgrammingBookmarks, JbossTips
Added:
>
>
 

Books

http://www.mindview.net/Books/TIJ/ - Bruce Eckels Thinking in Java. I used Thinking in C++ to learn C++ and it was excellent, so it's likely that this book is, too.

Changed:
<
<
O-Reilly Nutshell Book
>
>
O'Reilly Nutshell Book. Nice to have, although I find that I use javadoc more and the book less these days.
 

Development Tools

Changed:
<
<
building: ant - "like make only without make's wrinkles"
>
>
building: http://ant.apache.org/ - "like make only without make's wrinkles." I can't remember the last time I worked on (or looked at) a Java project that built using make.

unit test: http://www.junit.org/ - "keep the light green to keep the code clean." I'm definitely test-infected, writing and running unit tests is becoming second nature.

  modelling: argouml - a UML modelling tool that can generate Java skeletons.

debugging: jswat

Changed:
<
<
database access: isql, squirrelsql

Profiling

There are many expensive commercial tools for profiling Java programs while they're running, but since Java has the JVMPI interface pretty much anyone can hook into the JVM at run time and find out what's going on. This is another category of programs where there seem to be far too many half-baked efforts, but here are my notes from a few hours of fooling around with various tools.

Mike's Profiler - http://mjp.sourceforge.net/ looks promising, has actual documentation and the maintainer seems to be maintaining it on an ongoing basis. The GUI is easy to understand. Unfortunately it seems to run very slowly and crash before JBoss can fully boot up. NOTE - I need to test 0.06 which has a statistical sampling mode

JTreeProfiler - http://sourceforge.net/projects/jcoverage/ this one streams to an XML file on a per method invocation basis so it's probably unsuitable for anything but trivial profiling (booting JBoss wrote a 2.3GB file). The analysis GUI is interesting and very graphical but hard to make sense of.

>
>
database access: http://www.squirrelsql.org/ - good, not great, database browser in Swing.
 
Changed:
<
<
JPerfAnal - http://sourceforge.net/projects/jperfanal/ can you think of a more unfortunate name for a performance analysis tool? In any case this guy seems to have the right idea in that he reads the stock Sun profiler output so he doesn't need a platform-specific library to gather data. Unfortunately his GUI is lame and there's not one word of documentation.
>
>

Infrastructure

 
Changed:
<
<
Extensible Java Profiler - http://ejp.sourceforge.net/
>
>
Java application servers are available from a bunch of commercial vendors like Sun, IBM, BEA, Oracle, etc but there are some compelling open source options, too. They tend to work well, and the price is right, but the documentation is often weak.
 
Changed:
<
<
JMP - http://www.khelekore.org/jmp/ GTK GUI, written in C.
>
>
J2EE: JBoss http://www.jboss.org/ is the leading open-source "J2EE" container. I put "J2EE" in quotes because it's Sun's trademark and JBoss has not yet been certified compliant with the spec, although that's in process. JBoss works well but the documentation (even the stuff you pay for) is weak. It comes with an integrated Tomcat servlet container so it's a good way to get started with J2EE.
 
Changed:
<
<
JRat - http://jrat.sourceforge.net/ takes an interesting approach - you "instrument" your code after you build.
>
>
Servlet: Tomcat http://jakarta.apache.org/tomcat/ is the reference implementation of Servlets and JSP. I've used it standalone and integrated with JBoss and it's pretty sweet. Back in the 3.x days it was slower than Jetty but I've heard that 5.x is comparable.
 
Changed:
<
<

Infrastructure

>
>
MVC: At some point Sun declared that Smalltalk's "Model View Controller" was the right way to implement web user interfaces. Without getting into the discussion of what constitutes a "model" in a stateless environment, there are many frameworks to help you build web applications. http://jakarta.apache.org/struts/ Struts is by far the most popular, and is the only one I've seen with enough market share to become a resume buzzword. Many people aren't fond of Struts, which is one reason why there are so many me-too application frameworks. I'm fond of one called Maverick http://mav.sf.net/ which is very simple and elegant. It doesn't include a lot of what Struts does (form processing, validation, tag libraries, etc) but its basic flow is very cool - a simple XML file describes pipelines that start with a DOM-ified representation of Java objects and pass through multiple processing stages. It works well with XSLT.
 
Deleted:
<
<
tomcat - servlet engine, jboss - j2ee container, openejb - ejb container, avalon - server framework, maverick - presentation framework
 

Coding Conventions

Line: 71 to 68
  Java is very resource-intensive: cpu, memory, and processes. So you might bump into the limits that Unix uses to limit individual user resource consumption. An important one is max user processes which you can see if you run ulimit -a. You probably want to bump this up to 1020 or so: ulimit -u 1020. Other limits that you might bump into are SHMMAX and SHMANY which you can set using files in /proc/sys/kernel/ or by setting values in /etc/sysctl.conf.
Added:
>
>

IBM JVM on Linux

IBM's JVM 1.4.1 for GNU/Linux doesn't seem to recognize old-style timezone names. My /etc/localtime was a link to /usr/share/zoneinfo/US/Eastern and the JVM would never use daylight savings - it was always GMT+5. When I changed the link to /usr/share/zoneinfo/America/New_York it worked fine. See http://www.mainframeforum.com/t590240.html which seems to be relevant despite being a mainframe forum.

public class date { public static void main(String[] argv) throws java.io.IOException {System.out.println(new java.util.Date()); }}

 

Arrays vs Collections

Changed:
<
<
Why don't people use arrays in Java? It seems to me that people get so excited about Collection, Set, List etc that they forget about arrays. Arrays have some definite issues, but they also have some advantages. Arrays are fixed-length so they're not good if you're not sure how many things that you're going to put into them in advance. Their big advantage (which limits their use) is that they're strongly typed. This can be a big advantage in many cases, i.e. where you've got a bunch of the same thing. In this case an array is nice because it enforces type safety in a way that a Collection doesn't.
>
>
Why don't people use arrays in Java? It seems to me that people get so excited about Collection, Set, List etc that they forget about arrays. Arrays have some definite issues, but they also have some advantages. Arrays are fixed-length so they're not good if you're not sure how many things that you're going to put into them in advance. Their big advantage (which limits their use) is that they're strongly typed. This can be an advantage in many cases, i.e. where you've got a bunch of the same thing. In this case an array is nice because it enforces type safety in a way that a Collection doesn't.
  In summary, an array is the correct data structure to use where you have a known number of objects all of the same type.
Line: 127 to 130
 
Changed:
<
<

Misc Notes

>
>

Profiling

 
Changed:
<
<
IBM's JVM 1.4.1 for GNU/Linux doesn't seem to recognize old-style timezone names. My /etc/localtime was a link to /usr/share/zoneinfo/US/Eastern and the JVM would never use daylight savings - it was always GMT+5. When I changed the link to /usr/share/zoneinfo/America/New_York it worked fine. See http://www.mainframeforum.com/t590240.html which seems to be relevant despite being a mainframe forum.
>
>
There are many expensive commercial tools for profiling Java programs while they're running, but since Java has the JVMPI interface pretty much anyone can hook into the JVM at run time and find out what's going on. This is another category of programs where there seem to be far too many half-baked efforts, but here are my notes from a few hours of fooling around with various tools.

Mike's Profiler - http://mjp.sourceforge.net/ looks promising, has actual documentation and the maintainer seems to be maintaining it on an ongoing basis. The GUI is easy to understand. Unfortunately it seems to run very slowly and crash before JBoss can fully boot up. NOTE - I need to test 0.06 which has a statistical sampling mode

JTreeProfiler - http://sourceforge.net/projects/jcoverage/ this one streams to an XML file on a per method invocation basis so it's probably unsuitable for anything but trivial profiling (booting JBoss wrote a 2.3GB file). The analysis GUI is interesting and very graphical but hard to make sense of.

JPerfAnal - http://sourceforge.net/projects/jperfanal/ can you think of a more unfortunate name for a performance analysis tool? In any case this guy seems to have the right idea in that he reads the stock Sun profiler output so he doesn't need a platform-specific library to gather data. Unfortunately his GUI is lame and there's not one word of documentation.

Extensible Java Profiler - http://ejp.sourceforge.net/

JMP - http://www.khelekore.org/jmp/ GTK GUI, written in C.

JRat - http://jrat.sourceforge.net/ takes an interesting approach - you "instrument" your code after you build.

 
Deleted:
<
<
public class date { public static void main(String[] argv) throws java.io.IOException {System.out.println(new java.util.Date()); }}
  -- TobyCabot - 28 Dec 2001 - 10 Nov 2003
View topic | History: r36 < r35 < r34 < r33 | More topic actions...
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback