Invoking javac within an application

I'm trying to track down a JDK 1.0 technology, and am wondering if Sun still supports it.
I'm creating an editor in Java2, and would like to provide the users with the ability to write 'scripts' within the editor. The idea would be that the user could use a edit box to write in pure java, as if they were writing the body of a member function. Then, my editor would take the user's 'script' and generate a secondary .java file that splices the 'script' into the body of a member function. The .class file this .java file generates would then be available to a secondary Java2 program that takes as input the various files that were created by my editor.
I would like to provide some sort of interactive debugging for my user. One way to do this is to have my editor generate the .java file, call javac to compile it, and then report any bugs to the user (after adjusting the line number of the bugs to reflect what the user sees in their script window). One way to do this is to call javac externally and parse it's output, but I'd like a pure java solution.
In the Sun's JDK 1.0, there was a sun.tools.javac.* library, but these seem to have been removed from subsequent distributions. I understand that they're still available, but throw depreciation messages whenever they are called. There is also no mention of it in the JDK 1.4 documentation.
My question is: how do I invoke the javac compiler within Java2, and where can I find the supporting documentation?
A few people on comp.lang.java suggested I use BeanShell, and while it looks like a neat tool, I'm looking for something that will fit into my scheme of dynamically creating new .java files.
Mark McKay
http://www.kitfox.com

I don't have a definitive answer, but a good place to look might be the Ant source code. Ant uses sun.tools.javac.Main extensively.
I have the source on my desktop and took the liberty of copying a portion of the Ant taskdef for compiling with JDK 1.3. The source I've copied from is the org.apache.tools.ant.taskdefs.compiler.Javac13 class. If you look in that class, you'll see the use of other compilers for other versions of Java as well.
sun.tools.javac.Main is in the tools.jar file in your Java distribution.
Hope this helps:
* The Apache Software License, Version 1.1
* Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
* reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in
*    the documentation and/or other materials provided with the
*    distribution.
* 3. The end-user documentation included with the redistribution, if
*    any, must include the following acknowlegement:
*       "This product includes software developed by the
*        Apache Software Foundation (http://www.apache.org/)."
*    Alternately, this acknowlegement may appear in the software itself,
*    if and wherever such third-party acknowlegements normally appear.
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
*    Foundation" must not be used to endorse or promote products derived
*    from this software without prior written permission. For written
*    permission, please contact [email protected].
* 5. Products derived from this software may not be called "Apache"
*    nor may "Apache" appear in their names without prior written
*    permission of the Apache Group.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation.  For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
        // Use reflection to be able to build on all JDKs >= 1.1:
        try {
            Class c = Class.forName ("com.sun.tools.javac.Main");
            Object compiler = c.newInstance ();
            Method compile = c.getMethod ("compile",
                new Class [] {(new String [] {}).getClass ()});
            int result = ((Integer) compile.invoke
                          (compiler, new Object[] {cmd.getArguments()}))
                .intValue ();
            return (result == MODERN_COMPILER_SUCCESS);
        } catch (Exception ex) {
            if (ex instanceof BuildException) {
                throw (BuildException) ex;
            } else {
                throw new BuildException("Error starting modern compiler",
                                         ex, location);
        }

Similar Messages

  • Automating PDF which is embedded within SAP Application

    Hi all,
        I am facing the below mentioned problem.
    Automating PDF which is embedded within SAP Application
    In this case, we need to do some navigations within the PDF like selecting values in the drop-down, checking checkbox etc.
    We tried installing Aptt plug-in in our system and recorded using the AcroQTP add-in but still the object gets recognized as one window object.
    I tried with different combinations of selecting addins like SAP-Web-VB-AcroQTP, AcroQTP-Web and Acro-QTP.
    In all the three cases, the PDF was recognized as one window object.
    The details of the application and QTP is,
    QTP - 9.5 version
    IE - 6.0 version
    Application Technology - SAP
    Pls let me know if there are any work arounds for this problem.
    Thanks,
    Jayakrishna.S

    Hi JaiKrishna,
    I have encountered same problem while working SAP application. We have installed the following on our systems:
    1. Acrobat 9.4
    2. QTP 10
    3. AcroQTP plugin
    The addin manager displays the plugin but while recording/spying the objects are identified as WinObject on the PDF which is invoked through SAP application.
    Could you or anyone from forum can help us out to solve this problem?
    Many Thanks,
    Deepthi

  • I have an iMac with 2 internal drives and set-up with multiple user accounts.  How do I create a path to store data files on my second drive within an application?

    I have an iMac with 2 internal drives and a multiple user account set-up.  Hw do I create a path to store data files on the second drive within an application?

    This is the Mac mini forum not the iMac forum however...
    Applications written for average users like Photoshop, Word, i.e. GUI based applications provide a 'Save' dialog box which while allow selecting second drives or any drive. The dialob box initially shown might be in the simple mode but you just need to click on the triangle to show the full set of options. You should then see the different drive names amongst other options.
    If your referring to an application your writing yourself then you need to build a pathname. This can be in one of two styles depending on the programming system your using. This could be a POSIX style path or a Mac style path.
    POSIX = /Volumes/volname/foldername
    Mac style = Volname:foldername:

  • Timecapsule - opening files from within an application!!

    I have a time capsule... 500Mb
    I have an airport extreme with external hard drive - 250 Mb.
    Through Finder, I can place files on either of these drives and open them from Finder.
    If I open Numbers, or Pages, then try to open any file on Timecapsule, it appears that there are no files
    If I open Number, or Pages, then try to open any file on the Airport Extreme external disk - it works!
    Simple question really.... why cannot I see or open any file from within an application that resides on Timecapsule?? It's driving me crazy!!!
    Message was edited by: GrahamDurkin

    File dialogs have the ability to "group" items, which prohibits you from changing sort options.  The group icon looks like six little squares.  Click on it and instead of grouping by date, group by "none" and then you can change sort orders.

  • Viewing processor utilization within the application?

    I need to view the processor utiliation from within my application. Is there a call I can make to the operating system or does LabVIEW have the capability to do it? Thanks in advance.

    If you have LV7 and have installed the .Net framework there is an example included with LV called SimpleTaskMonitor.vi, it does just that - using .Net
    MTO

  • Max number of pages within an application

    Hi Gurus,
    Does somebody know if there is a limitation in term of number of pages within an application ?
    Thks in advance.
    Thierry

    We have apps with several hundred pages (I think 350 is the most we have in a single app). I think the real issue is how many total pages you have (all apps, all workspaces) as this could theoretically cause performance issues. Fortunately, the nice folks at Oracle have a real world scenario that will continue to outpace just about anything else--the hosted ApEx environment. It has thousands of workspaces with an incredible total number of pages. I have not experienced any issue with that environment, so I think the rest of us are quite safe.
    Anton

  • HTTP POST within an application

    hi, i am very new to java and just reached my next problem ;)
    what i want to do is post some data to a webserver from within my application and get the answer of the server back to a string (or something like that).
    what do i have to do for this?

    Hey there-
    You need to use the HttpURLConnection class to get connected to your web server. To get this you create a new URL object pointing to the web server, then cast the object returned from your URL's openConnection() method to be an HttpURLConnection - something like:
    URL myURL = new URL("http://something.com");
    HttpURLConnection httpURLCon = (HttpURLConnection)myURL.openConnection();Then you need to make your post. Do this by adding your data elements to the HttpURLConnection's request properties via the setRequestProperty method, like:
    httpURLCon.setRequestProperty("Name", name);Then you set up the connection for a post by setting its request method to "POST" (use the setRequestMethod method) and call setDoOutput(true) and setDoInput(true). This says you are doing a POST, and you want to both write the data out, and read what comes back.
    Finally you want to make the post and read the result from the server. You do this by writing your data to the output stream of your HttpURLConnection object and then reading data from its input stream, doing something like:
    // Send the data
    DataOutputStream dos = new DataOutputStream( httpURLCon.getOutputStream() );
    dos.writeBytes( data );
    dos.close();
    // Read the results
    DataInputStream dis = new DataInputStream(httpURLCon.getInputStream() );
    String nextLine = null;
    StringBuffer results = new StringBuffer();
    while((nextLine = dis.readLine()) != null) {
        results.append(nextLine + "\n");
    dis.close();That should do it.
    Good luck to ya
    Lee

  • Command -` for switching windows within an application

    I ran an update to 10.6.5 last week and suddenly I appear to be unable to scroll between tabs within an application using Cmd - `.
    For example, using safari i was able to scroll between tabs using this keyboard shortcut, and in excel I was able to scroll between Workbooks.
    I have the option checked under
    System Preferences | Keyboard | Keyboard Shortcuts | Keyboard and Text Input | Move focus to next window in application = ⌘`

    This application will.
    http://www.keyboardmaestro.com/main/
    -Bmer
    Mac Owners Support Group
    Join Us @ MacOSG.com
    ITMS: MacOSG Podcast
     An Apple User Group 
    Note: I receive no compensation for product endorsements.

  • Is the anyway to get a report of component usage within an Application.

    It would sure be 'nice' to have a report of the component usage within an Application. I am most interested in where the LOVs are being referenced. It is extremely time consuming to check every report/form item by item. I'm sure this information is available 'somewhere' within the Portal schema but I don't know where. Anyone got any ideas? Thanx in advance

    Such info can be obtained from Portal schema.
    Those tables are not granted to public.
    How do you plan to use it? For your own maintain purpose?

  • Website not found error within CRM application

    Hi,
    One of our user says he is getting 'Web site not found' error within CRM application. What could be the issue ?
    We are using CRM 5.0

    Hello,
    What application is your user trying to access ? Is it the ICWC or PCUI?
    regards
    Mark Foley

  • Outlook 2010 Terminal Services; Error when sending mail "Content within this application coming... "About:Internet"

    Hi All,
    We have Outlook 2010 running on Terminal Services for one of our clients. Frequently users experience an error when trying to send mail.  A message pops up stating the follow (sorry I cannot post pictures or links yet which would make this much easier)
               "Content within this application coming from the website listed below is being blocked by Internet Explorer Enhanced Security Configuration."    About:Internet
    If I try to add this to the Trusted Sites zone it tells me that I have already done so.  All users are experiencing this issue. Not sure what can be done from our end to alleviate this problem.  Any advice?

    Either remove this "About:Internet" or disable Internet Explorer Enhanced Security Configuration on the terminal server:
    To disable IE ESC for all users
    Close all instances of Internet Explorer.
    Click Start, point to Administrative Tools, and then click
    Server Manager.
    If a User Account Control dialog box appears, click Continue.
    Under Security Summary, click Configure IE ESC.
    Under Administrators, click Off (Recommended).
    Under Users, click Off (Recommended).
    Click OK.
    Worked for me. Thanks!

  • Initiate a human task within worklist application

    I got some questions regarding human task and worklist app
    1. Is it possible to initiate a human task within worklist application? For example: jcooper initiate a request for expense straight from his worklist app
    2. I see in jazn configuration. There is a bpm worklist view history role. Where do I access to history of all tasks already ended.
    3. If a task is ended is it possible to bring it back alive?
    Thank you in advance

    Hi,
    Check out the Java API that Oracle provides for the Worklist Application. It allows all sorts of customizations / task interactions. A good starting point is the BPEL Developer's Guide.
    Enjoy, Sjoerd

  • What Xcelsius binaries are needed and how does licensing work when including within an application?

    Hi Folks,
    Could anyone tell me what binaries ( swf, flash, xml, etc..) are needed if I want to run Xcelsius from within another application?  Do they need to be in the same folder?
    Also, how are licenses used, stored, retrieved for Xcelsius when included in another application?
    Thanks,
    Karun

    Are you wanting to run the Xcelsius-created .Flash file (.swf) from within another application - or are you asking about running Xcelsius itself from within another app?

  • How to upload data within apex application? just like the utility does

    Hi,
    We have an application of apex, we need to input a lot of data from Excel type form to apex. We print the report/form in excel, and then we input them into the app application.
    sometimes it is very time consuming for the end users of the app inputting data within the app itself, with either single row form or tabular form.
    So, I often input data by myself by means of application express s*ql workshop, utilities/data workshop, copy/paste* , but the problem is that you should the know the underline table names for those input datas.
    So it is not good if I let my end users input data directly by means of data workshop.
    So, is it possible that I make a data workshop like stuff within my application, that my end users can upload data with it?
    Thanks,
    Peter
    Edited by: Yawei Zhang on Nov 4, 2010 8:10 AM

    Hi,
    This might help
    Import excel file through a APEX page and store the data into database
    Regards,
    Jari
    Edited by: jarola on Nov 4, 2010 2:18 AM
    See this also , if you use Apex Listener
    http://krisrice.blogspot.com/2010/02/another-apex-listener-ea-more-knobs-to.html
    Edited by: jarola on Nov 4, 2010 2:22 AM
    And I find this also
    http://jon-trostheim.blogspot.com/2010/01/drag-and-drop-data-from-excel-into-apex.html
    And Denes Kubicek have write about external tables. There is 3 samples
    http://apex.oracle.com/pls/otn/f?p=31517:88
    And if you search forum and bit Google, you find lot of solutions

  • Copy application from within an application?

    Ok, this may be a bit of a stretch, but is it possible to create a new application as a copy of an existing one from within an application?
    To explain: I'm envisioning an APEX framework where I have a "core" application which has all of my standard functionality built in; whenever I want to build a new application, I copy that, rather than building a new one from scratch. Information about the applications (active status, authentication method, created by, last modified by, description, etc.) would be stored in a central (custom) table (this much has been covered by Scott Spendolini in this presentation).
    So, I'd like to build an application which would show me the data from this central table, and also have a wizard that would a) copy the core application to a new ID, potentially setting some features in the process, and b) create the appropriate record in the central table.
    Thanks,
    -David

    David,
    I am having the same thoughts and will watch this thread. I believe what you are referring to is "subscribing to a master application" of which I have no experience in.
    Just saw another thread similar to this one:
    See {thread:id=1774693}
    Jeff
    Edited by: jwellsnh on Nov 22, 2010 1:58 PM

Maybe you are looking for

  • [Solved] mga crashes xorg

    Hi all. I have a Matrox Millennium II and every time i use mga (xf86-video-mga) on the Screen section of xorg.conf, the Xorg crashes. I have tried to use the xorg.conf generated by Xubuntu 7.10 (which runs great on that distro) on Arch, but no succes

  • Impdp work with system but doesn't work with another user

    Hi, We have troubles with import of transportable tablespace, when i try to import it with system the import is done currectly, when i try to use another user we receive this message : impdp bmcese/***** directory=TTS_DIR dumpfile=RMCCO_RMC_ANA_STS_A

  • Exporting to pdf changes the resolution

    Good day, I have a document 800px wide in InDesign. When I export it to .pdf and set to 100% zoom it's way more than 800px. The exported .PDF at 100% zoom takes about 1200px instead of 800px and looks awful!! If I export it to .JPG it will export cor

  • Dead Lock occured while Sync index in oracle text

    Hi All, We are facing dead lock issue which syncing the oracle text index . The index is built on the local partitioned table and the sync index has the parameters below, parallel - 4 memory - 20M the error message is, System error: Plsql job executi

  • Addition to stock in storage bin

    Hi, in the customizing LE-WM-Master data-Define Storage Type  I have defined for storage type 500 that addition to stock is not allowed, so all the bins created in this storage type are not going to allow addition to stock even though in materials ma