home *** CD-ROM | disk | FTP | other *** search
/ Hacker 7 / HACKER07.ISO / Utils / TPE32323.EXE / RUNJAVA.BAT < prev    next >
DOS Batch File  |  1998-05-27  |  1KB  |  42 lines

  1. @ECHO OFF
  2. REM Copyright (C) Cay S. Horstmann 1997. All rights reserved.
  3. REM Distributed with TextPad with the permission of Cay S. Horstmann,
  4. REM (www.horstmann.com) joint author of "Core Java" (ISBN 0-13-596891-7).
  5. REM
  6. REM This crazy batch file does the following.
  7. REM 1. It finds if the .java file contains the word Applet. If so, it assumes
  8. REM    it is an applet. So don't confuse it with silly things like displaying
  9. REM    "This isn't an applet."
  10. REM 2. If it is an applet, it makes a quick-and-dirty HTML file. I am giving
  11. REM    it the extension .HTM so that your well-crafted HTML files aren't
  12. REM    overwritten. The weird sequence of quotation marks is necessary because
  13. REM    ECHO can't echo unquoted "<" and ">" characters
  14. REM 3. If it is an applet, appletviewer is started. Otherwise the java
  15. REM    interpreter is started.
  16. REM 4. If it is a console applet (not deriving from Frame), then the batch
  17. REM    file pauses for you to admire the output.
  18.  
  19. if "%1"=="" goto end
  20. if not exist %1.class javac %1.java
  21.  
  22. find "Applet" %1.java > NUL:
  23. if ERRORLEVEL 1 goto notapplet
  24.  
  25. echo "<APPLET CODE="%1.class" WIDTH=400 HEIGHT=300 IGNORE=""></APPLET>" > %1.HTM
  26. REM Mercifully, appletviewer ignores the quotes outside the Applet tag
  27. appletviewer %1.HTM
  28.  
  29. goto end
  30. :notapplet
  31. find "Frame" %1.java > NUL:
  32. if ERRORLEVEL 1 goto notframe
  33.  
  34. java %1
  35. goto end
  36.  
  37. :notframe
  38. java %1
  39. pause
  40.  
  41. :end
  42.