27 July 2008

Viewing Dependencies with Eclipse

Dependencies between classes are somehow double faced. Classes need other classes to do their work because code has to be broken down into small chunks to be easier to understand. On the other hand, growing quadratic with the number of classes (n nodes can define up to n*(n-1) directed edges in a graph), they can be a major source of code complexity: Tight coupling, Feature Envy and cyclic dependencies are only some of the problems caused by relations between classes "going wild".

I try to avoid (too many) usages of other classes in my source. But it's not that easy. Consider a class in some legacy code base that shows signs of Feature Envy for classes in another package. Should I move it there? To be sure I need to know all classes my class is dependent upon? I mean all classes, so checking imports does not help. Even if I forbid wildcard imports (what I do), that are still not all classes. Classes in the same package are rarely shown by tools. Even my favourite Code Analysis Plugin (CAP) for Eclipse does not show them.

So here is my little, crappy, amateur Java Dependency View Plugin for Eclipse. Unpack it and put the jar into Eclipse's plugins directory. Restart Eclipse and open the Dependency View.open Dependency View in Eclipse with Open View
(The small blue icon is my old coding-logo, a bit skewed.) In the view you'll see all kinds of outgoing references: inner classes, classes in the same package, other classes, generic types and sometimes - a bug in the view. Dependency View in Eclipse showing all outgoing references of java.util.ArrayList
The plugin was developed with Eclipse 3.2 and tested in 3.3. Source code is included in the jar.

A nice feature, that I was not able to implement would have been reverse search, i.e. a list of all classes depending on the current selected one. If you happen to know how to to that, i.e. how to search for all classes that refer the current class, drop me a note.

23 July 2008

DOS Commandline Tools

A Bit of History
I always liked coding, right from my very first line of Basic back in 1986. Later I did some 65xx-Assembler work and in 1991 I finally went for Turbo Pascal. During the nineties I created a lot of stuff for MS-DOS based systems either during university projects or just for fun. Being a lazy programmer, I produced a lot of tools to perform repetitive tasks more easily. DOS and Windows never shipped with many utilities, unlike other operation systems. (Today there are Windows ports of more powerful tools available.)

Recently, when reorganising all my historic code I recovered these command-liners. Well, good old Turbo Pascal is definitely out-dated and most executables wouldn't even run any more. The reason is that the CRT unit as supplied by Borland has a few defects causing RTE200 on fast computers or at least inconsistent delay problems. Fortunately there are CRT Replacement Units for Turbo & Borland Pascal Compilers which fix all these problems. So I spent some time recompiling all my 280k lines of Pascal code. Now they work on newer computers as well. The tools are divided into several groups: Data-File-Hacking, File-Utilities, Image-, Sound/Music- and Text-Manipulation.

Rusty Ring Most of the tools provided here were created in 1994 to 1998. They were developed for 16 bit MS-DOS based systems and do not support long file names or recently introduced file formats. Most likely some of them are superseded. Use them at your own risk! Almost all tools show their usage when called with parameter "-?" or "/?". Unfortunately the help messages are in German... Some of them are highly experimental. and some are probably totally useless. I say it again, use them at your own risk!

The Data-File-Hacking package contains programs for disassembling, extracting data from files and memory, extracting files from special data files of some games, hex- and eor/xor-representation of binary data and extensive search and compare procedures. (Download hacking tools).
  • ????HACK contains code to "hack" i.e. unpack or uncompress data files of certain games.
  • BIN2HEX converts binary data into hex table text file.
  • BIT2BYTE expands every bit of binary data to a full byte.
  • BUB2ASM converts Bubble-Asm format into TASM-Asm (prefix hex numbers with 0).
  • BYTE2BIT compress every byte with value != 0 to a set bit, else not set bit.
  • CHANGBYT changes a single byte in a file.
  • CUTBIN removes the first bytes of a binary file.
  • CUTBYTES removes bytes of a binary file starting at a certain offset.
  • CUTNOP removes all lines from a text file that start with 90<space> (NOP command).
  • CV2ASMDB converts CodeView output into ASM "DB" format.
  • CV2INLIN converts CodeView output into Turbo Pascal inline assembler format.
  • EOV exclusive-or viewer to find byte sequences of 'protected' files.
  • EXTRACT extracts parts of files from larger files.
  • HEX converts hex, decimal, octal and binary numbers into each other.
  • HEX2BIN converts a sequence of hex number into a binary file.
  • HEXTSR (TSR) shows hex conversion window on key stroke ALT-S.
  • MEMLOAD loads binary data into memory without executing it.
  • MEMSAVE saves memory contents to a file.
  • MEMSVCNV saves contents of conventional memory to a file.
  • MEMSVXMS saves contents of free XMS memory to a file.
  • MEMTSR (TSR) saves memory contents to a file on key stroke ALT-S.
  • RECH calculates arithmetic expressions.
  • SAVESCRN saves current contents of video text memory to a file.
  • SCRNTSR (TSR) saves current contents of video text memory to a file on key stroke ALT-S.
  • VOCEXTR finds and extracts Creative Labs Voice (VOC), Wave (WAV) and XMidi (XMI) from larger files.
  • WADIT edits and displays contents of ID software's WAD files (DOOM data files).
  • WAVEXTR finds and extracts RIFF Wave and IFF files from larger files.
  • XADD adds/xors all bytes of a file to a checksum.
  • XCHGBYTE replaces or swaps specific values in binary files.
  • XCOMP extended version of DOS COMP.
  • XSEARCH searches several files simultaneously.
  • XSEQUENZ searches results of XCOMP runs for ascending/descending sequences.
  • XWHAT prints the value of a certain position in files.
  • XWHAT2 prints all the value of a certain position in files.

File-Manipulation features tools for comparing, renaming, setting time and date, wildcard operations and hardware detection. (Download file tools.)
  • BRAKE! slows down CPU using busy waits in interrupt 8 (INT08).
  • CHKFILES reads files from disk to check their integrity.
  • DETECT ultimate hardware detection and benchmark tool.
  • DFOR executes a DOS command for all file names in a list.
  • DUPLICAT calls COPY to duplicate directory trees, copies only new files.
  • FILLDISK calculates somehow optimal distribution of files when saved to floppy disks.
  • GETTIME measures the time another DOS command needs to execute.
  • ISWIN checks for currently running Windows 3.1 or 95.
  • LENCOMP compares files similar to COMP but based on length, ignoring path and name.
  • NOTHING Do Nothing Loop.
  • RENALL renames a wildcard file set according to a name list.
  • SCOMP compares files similar to COMP and deletes identical ones.
  • SFOR executes a DOS command for a wildcard file set.
  • TDIR lists files similar to DIR with their date time to be used for TTDAT.
  • TIMETOUC (or short TT) changes the date and time of a file.
  • TO searches for a directory and changes current working directory to there.
  • TTDAT executes TIMETOUC for a list file produced with TDIR.

Field Working Tools
The Image-Manipulation collection provides help for viewing header information of images, viewing special picture formats, viewing special animation formats, palette manipulation, Windows BMP generation and font designing and using. (Download image tools.) Some of the tools need a VESA compatible driver to display images in SVGA graphics mode.
  • ANIM creates an rotating animation from a Bitmap (BMP).
  • ANM plays 320x200x256 sized ANM animations (with LPF ANIM magic bytes).
  • APAL2BIN converts ASCII RGB-palette into binary.
  • BGI2DOOM converts Turbo Pascal's BGI images into Doom 1.2 textures.
  • BMP2ASC converts 640x400x256 sized BMP into an ASCII image.
  • BMP2BGI converts uncompressed BMP into Turbo Pascal's BGI format.
  • BMP2DRW converts 80x50x16 sized BMP into my own DRW format for display in text mode.
  • BMP2PAL saves colour palette of a BMP.
  • BMP2PLAN converts 640x480x16 sized BMP into 4 colour planes.
  • BMP2RAW converts 320x200x256 sized BMP into raw-format.
  • BMP2TXT converts BMP into ASCII image depending on brightness values.
  • BPAL2ASC converts binary RGB-palette (768 bytes) into decimal text format as needed for RAW2GIF.
  • COLTABL displays table of DOS colours.
  • DRAWPIC editor for drawing 80x25 DRW image files.
  • DRAWTXT editor for drawing ASCII images.
  • FNTMAGIC editor for drawing 16x8/8x8 fonts.
  • FONTHACK displays binary data as 16x8/8x8 fonts.
  • FONTVIEW displays an F16 font.
  • GIF2BGI converts a GIF into one or more BGI images.
  • GIF2SPR converts 160x160 sized GIF into 64 BGI images useable as sprites in games.
  • GIFHEAD displays header information of GIF images.
  • HLS2RGB converts ASCII HLS-palette into ASCII RGB-palette.
  • KPACK compresses in my own R9 format, similar to RLE8 with slightly better compression.
  • LINESET set number of lines text mode (25, 28, 33 or 50).
  • PACK compresses files with RLE algorithm.
  • PACKFL4 compress 4-bit animations with distinct frames, my own FL4 format.
  • PAL2BMPP converts binary palette into BMP palette with empty padding.
  • PLAY plays 320x200x256 sized Autodesk FLI and 640x480x256 sized FLC.
  • PLAYFL4 plays 640x480x16 sized FL4 animation.
  • PLAYFLI plays 320x200 sized Autodesk FLI and FLC animation.
  • RAW2BMP converts RAW images into BMP.
  • RGB2HLS converts ASCII RGB-palette into ASCII HLS-palette.
  • SETBORD sets border colour in console.
  • SETFONT sets an F16 font in console.
  • SHOWBMP displays unpacked 1024x768x256 sized BMP.
  • SHOWC64 displays Commodore 64 Koala Painter and other image formats.
  • SHOWGIF loads a few GIFs into XMS memory, displays and cycles them (mini slide show).
  • SHOWIT displays GIFs and slide shows of GIFs using external VPIC.EXE.
  • SHOWPAL displays colours of a palette.
  • SHOWPIC displays arbitrary data as colour values of an image.
  • SHOWRAW displays arbitrary data as 16 or 256 colour values of an image up to 1024x768x256.
  • SHOWSVGA (or short EV) displays arbitrary data as colour values of an image up to 1280x1024x256.
  • SHOWVGA displays arbitrary data as VGA image (320x200x256), part of EOV.
  • TXT2BMP converts text into 80 times lines sized BMP.
  • TXT2RAW converts text into 80 times lines sized raw image data.
  • UNPCKFL4 unpacks and displays 4-bit animations (FL4 files).
  • UNRLE8 unpacks RLE8 compressed files.
  • XCOLOR changes specific colour values of a BMP in image data, not in palette.
  • XTRC_BMP extracts sub-image out of an uncompressed BMP into a new BMP.

The Sound/Music-Manipulation tools support conversion of special sound formats into common formats and between different types of formats, playing of VOCs, WAVs and XMidis via Soundblaster and PC-Speaker and getting header information of audio files. (Download sound tools.) To use your audio hardware you need a DOS styled driver emulator like VDMSound.
  • AMIG2SND converts Amiga signed raw sound data (SND) into PC format.
  • DWD2SND converts DiamondWare digitised data into SND format.
  • MAC2SND converts Apple Mac sound data (SND) into SND format.
  • MANYINST lists instruments of an XMidi found in the *.ad file.
  • MIDHEAD displays header information and event list of Midi files (MID).
  • PAWE plays XMidi (XMI) using AWE32 hardware.
  • PCM2VOC converts Space Hulk PCM into VOC.
  • PCM2WAV converts AquaNox's PCM into WAV.
  • PCMF plays Creative Music File (CMF), needs SBFM to be started before.
  • PCMF17 plays CMF.
  • PMID plays XMidi using Midi hardware.
  • PMPU plays XMidi using MT32MPU hardware.
  • PSOUND plays sound files like VOC and WAV using PC speaker hardware.
  • PVOC plays VOC.
  • PWAV plays WAV.
  • PXMI plays XMidi using Soundblaster hardware.
  • RAW16TO8 converts raw 16 bit samples into 8 bit by ignoring every second byte.
  • RAW2SGN converts signed into unsigned samples by adding 080h.
  • RAW2SND converts raw samples into SND format.
  • SAM2WAV converts Modplayer Sample data (SAM) into WAV.
  • SND2WAV converts SND into WAV.
  • SYN2WAV split SYN data files into separate WAVs.
  • VAC2WAV converts VAC, RAC and MAC (ST-TNG CD, 11025Hz) into WAV.
  • VCMF plays all CMFs in the current directory, needs SBFM to be started before.
  • VCMF17 plays all CMFs in the current directory.
  • VMF2WAV converts Creatix sound 4800Hz (VMF) into WAV.
  • VMPU plays all XMidis in the current directory using MT32MPU hardware.
  • VOCHEAD displays header information of VOC files.
  • VVOC plays all VOCs in the current directory.
  • VWAV plays all WAVs in the current directory.
  • VXMI plays all XMidis in the current directory.
  • WAV16TO8 converts 16 bit WAVs into 8 bit.
  • WAV2SAM converts WAV into Modplayer Sample data (SAM).
  • WAV2SYN combines several WAVs into a SYN.
  • WAV2VMF converts WAV into Creatix VMF.
  • WAV2VOC converts WAV into VOC.
  • WAVHEAD displays header information of WAV files.
  • WAVMIX mixes WAVs using different algorithms.
  • WAVMORPH morphs a WAV into another (very experimental).
  • WAVST2MO converts 8 bit stereo WAV into mono format.
  • XMIHEAD displays header information of XMidi files.
  • XMITRACK extracts single tracks from a multi-track XMidi.

Abandoned to nature
Text-Manipulation (ASCII) offers methods for converting, replacing, sorting and different kinds of removing of pieces of text in text files. (Download text tools.)
  • ASCTABL displays table of ASCII characters.
  • ASCTABL2 displays table of ASCII characters together with their decimal values.
  • BIN2ASC removes all bytes 0-31 from a file to edit it as text.
  • C64TOASC converts Commodore 64 text into ASCII format.
  • COPYLINE copies all lines of a text file which contain a search term.
  • CUT10 removes the first 10 columns in each line (for DIS86).
  • CUTLAST removes the last given characters in each line.
  • CUTLEAD removes the first given characters in each line.
  • CUTLINES removes every some lines some more lines, e.g. remove two lines every ten lines.
  • CUTPOS removes all text after a given column position.
  • CUTSPACE removes trailing spaces.
  • D2E replaces all 'D' with 'E', used to convert FORTRAN output into gnuplot data.
  • DELNEWS removes all lines of a text file which start with search term.
  • DELSPACE removes all double blanks.
  • DIR2HTML creates an HTML index file containing the current folder entries.
  • DIR2TEX creates a TeX index file containing the current folder entries.
  • DOC2TXT converts WinWord umlauts back into DOS characters.
  • DOWN converts all letters into lowercase.
  • EXP2DEZ converts scientific numbers (e.g. 1.3E-1) into decimal numbers (e.g. 0.13).
  • FIT2PIX reduces data points to one value per pixel, used for gnuplot and TeX.
  • FORM2TXT converts HTML form data into plain text.
  • GERADEN solves a linear equation.
  • GNUSUB subtracts values from the second column, used for translation of gnuplot data.
  • INSP2TEX converts INSPEC search results to LaTeX bibitems.
  • LINECNT counts the lines of a text file.
  • LINESORT sorts like SORT but blocks of lines instead of single lines.
  • LINESUB replaces whole lines of a text file, configured by line number.
  • MERGLINE merges two text files line wise (today's editors know this as 'column mode').
  • MOVE_TEX moves TeX elements inside EmTeX pictures.
  • NOSPACE removes all single blanks.
  • ROUND rounds all decimal numbers.
  • SEQ2TXT converts Commodore 64 sequential file data (SEQ) into PC char-set.
  • SKALIER scales numbers by a factor, used for gnuplot data.
  • SLIM_TEX removes all unnecessary horizontal \put(lineto), used for gnuplot and TeX.
  • STRIP_% removes all comments (%) from TeX source.
  • STRIP_C removes all comments from FORTRAN 77 source.
  • TASTCODE prints the key code of the pressed key.
  • TEST7BIT checks if a text only contains ASCII characters > 127
  • TEXTDEL removes every some lines some more lines, e.g. remove two lines every ten lines.
  • TEXTINS inserts a text file into another at a certain position.
  • TEXTSUB replaces characters in a text file.
  • TURNBACK save a file in reverse order, i.e. last byte first.
  • TURNLINE turn all lines backwards, i.e. from right to left.
  • UMBRUCH joins all lines and adds new line breaks at given position.
  • UP converts all letters into uppercase.
  • UP11 converts all letters and umlauts into uppercase.

8 July 2008

Eclipse Europa GlassFish Problems

OK, it's my fault. I do not RTFM, but usually try out the stuff immediately without much reading.

Recently I wanted to check out the GlassFish application server (version 2) together with Eclipse (version 3.3 or Europa) and encountered some problems. Here is my minimalist conclusion:
  • Download the latest version of GlassFish, in my case it was 2ur2-b04.
  • Read the documentation, there is more to do than just unpack the archive and start it.
  • Do it! Go there! Read it!
  • java -Xmx256m -jar glassfish-installer-v2ur2-b04-windows.jar is obvious...
  • Now comes an important part: Probably you do not want GlassFish to live in the /glassfish-folder, I would rather have it in something like /glassfish-2ur2-b04 for this version. So
  • Copy and/or rename the newly created and filled directory glassfish to your liking. This has to be done before you continue! You can't do that later.
  • Go into this folder and execute lib\ant\bin\ant -f setup.xml as shown in the GlassFish documentation. This should finish the installation.
For the integration of GlassFish with Eclipse, there is an excellent description on the GlassFish site. Unfortunately, there are still some holes in it (and of course I did not read it in the first place, remember, I do not RTFM :-)
  • To create a new server in Eclipse JEE perspective, use the "New Server" wizard in the "Server" tab. But where is GlassFish?
Eclipse Europa - New Server - where is GlassFish
  • So click on the "Download additional server..." link
  • When working behind a proxy, this may take long and not list GlassFish in the end. The reason is that an https-Proxy has to be configured in Eclipse.
Eclipse Europa - Network Settings SSL Proxy
  • Now you are able to create the new server. If the wizard tells you that it can't find some appserv-rt.jar, then you forgot to call ant -f setup.xml during installation of GlassFish (as listed above).
Eclipse Europa - GlassFish V2 - where is appserv-rt.jar
  • This is because GlassFish comes with it's jars in the pack200 format, which do not end with .jar but with .jar.pack.gz and are unpacked during installation. (Manually unpacking unpack200 lib\appserv-rt.jar.pack.gz lib\appserv-rt.jar does not help here. You need to call the set-up...)
  • Start the server. If you get error messages that the system can't find some path and the start-up fails with a timeout after a minute then you did not move/rename the /glassfish-folder to the desired destination before calling the setup.
  • This is because GlassFish has his scripts like asadmin.bat contain absolute paths written during setup, e.g.
    setlocal
    call "C:\download\glassfish\config\asenv.bat"
    set Path=%AS_INSTALL%\bin;%AS_ICU_LIB%;%PATH%
  • Enjoy the finally starting GlassFish, serving it's index page at port 8080:
GlassFish V2 or SunAppServer V9
Now is it GlassFish 2.2 or Sun's Application Server 9.1? ;-)