Java Doc for JavaUtils.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » common » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » cbesb 1.2 » com.bostechcorp.cbesb.common.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.bostechcorp.cbesb.common.util.JavaUtils

JavaUtils
public class JavaUtils (Code)
This class supports invoking Java compilation from within a Java program. Recent versions of the Java environment have provided such an API (in tools.jar). But that isn't available on all platforms, and a fallback to the command line may be needed (though this too may not always be available, eg. for security reasons).

There's an additional complication in some environments -- such as Microsoft's VJ -- where the classpath as seen in the System Properties may not be the one the user expects. The code here is parameterized to try to deal with that.



Field Summary
protected static transient  Loglogger
    


Method Summary
public static  booleanJDKcompile(String fileName, String classPath, String dir)
     Try to compile a .java file on disk.
public static  voidsetDebug(boolean newDebug)
     Control whether compilation occurs with the -g option (debugging information included in generated classfile). This is an attribute, rather than a parameter on the compile method, largely because it tends to be an all-or-nothing decision; generally you're either doing program development and want it, or running in production mode and don't.
static  intwaitHardFor(java.lang.Process p)
     Subroutine: Like p.waitFor, but discards the InterruptedException and goes right back into a wait.

Field Detail
logger
protected static transient Log logger(Code)





Method Detail
JDKcompile
public static boolean JDKcompile(String fileName, String classPath, String dir)(Code)
Try to compile a .java file on disk. This will first attempt to use the sun.java.tools.javac() method, then (if that is unavailable) fall back upon shelling out to a command line and running javac there.

NOTE: This must be _compiled_ with sun.java.tools.* (tools.jar) available. We could change that to use reflection instead, if we accept some overhead... minor compared to the cost of running the compiler!

This has complications on some platforms. For example, under Microsoft Visual Java (at least, as installed on my test system), I found that I had to specify paths to both javac and xerces.jar rather than counting on the shell's path and classpath having been set to reach these. For that reason I've parameterized this method with a few system properties, so you can adapt it to your own system's needs without modifying the code:

org.apache.xalan.utils.synthetic.javac
Command line issued to invoke the compiler. Defaults to "javac", which should work in most systems. In VJ, try setting it to "cmd /c %JAVA_HOME%\\bin\javac.exe"
org.apache.xalan.utils.synthetic.moreclasspath
Additional classpath, to be prepended to the one retrieved from java.class.path. Defaults to "" (empty). In VJ, try setting it to point to your copy of xerces.jar, which may not be found otherwise. TODO: Reconsider prepend versus append!

Parameters:
  String - fileName Which .java file to compile. Note that this maybe relative to the "current directory".
Parameters:
  String - classPath Additional places to look for classes thatthis .java file depends upon. Becomes the javac command's-classpath parameter value. boolean True iff compilation succeeded.



setDebug
public static void setDebug(boolean newDebug)(Code)
Control whether compilation occurs with the -g option (debugging information included in generated classfile). This is an attribute, rather than a parameter on the compile method, largely because it tends to be an all-or-nothing decision; generally you're either doing program development and want it, or running in production mode and don't. But that may not match the needs of future users...

TODO: Consider whether debug should be a parameter. boolean newDebug True to request debugging data,false to request optimized output. (It's uncommon towant both or neither!)




waitHardFor
static int waitHardFor(java.lang.Process p)(Code)
Subroutine: Like p.waitFor, but discards the InterruptedException and goes right back into a wait. I don't want to report compiler success or failure until it really has succeeded or failed... I think.
Parameters:
  Process - p to be waited for the exitValue() of the process.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.