Loading JavaFX code from string

Hi,
Here is my JavaFX code that I put to the SimplePainter.fx file:
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.input.*;
import javafx.scene.shape.*;
var elements: PathElement[];
Stage {
    title: "Simple Painter"
    scene: Scene {
        content: Group{
            content: [
                Rectangle{
                    width: 400
                    height: 300
                    fill: Color.WHITE
                    onMousePressed: function( e: MouseEvent ):Void {
                            insert MoveTo {x : e.x, y : e.y } into elements;
                    onMouseDragged: function( e: MouseEvent ):Void {
                            insert LineTo {x : e.x, y : e.y } into elements;
                Path{
                    stroke: Color.BLUE
                    elements: bind elements
}I am trying to use the ScriptEngineManager to evaluate the SimplePainter file:
import java.io.FileReader;
import javax.script.ScriptEngineManager;
var path = "C:/Temp/fx/SimplePainter.fx";
var manager = new ScriptEngineManager();
var engine = manager.getEngineByExtension("fx");
engine.eval(new FileReader(path));It throws AssertionError:
java.lang.AssertionError
at com.sun.tools.javac.jvm.Gen.visitBreak(Gen.java:1631)
at com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1167)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:679)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:714)
However the simple 'println("Hello World!")' code is invoked fine.
Do I do something wrong?
Is it possible to use JavaFX compile methods to execute a JavaFX code from string?
Thanks in advance.

I experimented with that a while ago with JavaFX 1.1, with success: [Creating JavaFX Classes from Java Classes then running?|http://forums.sun.com/thread.jspa?threadID=5368159]
I tried again:
import java.io.*;
import com.sun.javafx.api.JavaFXScriptEngine;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
class RunJavaFXScript
  static String SCRIPT_NAME = "Test.fx";
  public static void main(String[] args)
    // Get the current directory
    File curDir = new File(".");
    // Get the script's file content
    BufferedReader reader = null;
    File fScript = new File(curDir.getAbsolutePath(), SCRIPT_NAME);
    System.out.println("Reading the " + fScript.getAbsolutePath() + " script");
    try
      reader = new BufferedReader(new FileReader(fScript));
    catch (FileNotFoundException e)
      System.err.println("File not found: " + fScript.getAbsolutePath());
      return;
    // Create a script on the fly
    String script = "function Demo() { println('Hello World!'); return 'It works!'; }";
    System.out.println("Getting the engines");
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByExtension("fx");
    System.out.println("Getting the generic ScriptEngine (by extension): " + engine);
    JavaFXScriptEngine fxEngine = (JavaFXScriptEngine) manager.getEngineByName("javafx");
    System.out.println("Getting the JavaFXScriptEngine: " + fxEngine);
    // Try to run it
    try
      System.out.println("Running the script read from a file: " + reader);
      Object readScript = engine.eval(reader);
      System.out.println("Running a built-in script");
      Object internalScript = fxEngine.eval(script);
      Object r = fxEngine.invokeFunction("Demo");
      System.out.println("Returned: " + (String) r);
    catch (Exception e)
      e.printStackTrace();
    finally
      try { reader.close(); } catch (IOException e) {}
}Compiled with:
javac -cp %JAVAFX_HOME%/lib/shared/javafxc.jar RunJavaFXScript.java(with JAVAFX_HOME pointing at javafx-sdk1.1)
Ran with:
java -cp %JAVAFX_HOME%/lib/shared/javafxc.jar;%JAVAFX_HOME%/lib/desktop/javafxgui.jar;%JAVAFX_HOME%/lib/desktop/Scenario.jar;. RunJavaFXScriptIt works:
Reading the E:\Dev\PhiLhoSoft\Java\_QuickExperiments\.\Test.fx script
Getting the engines
Getting the generic ScriptEngine (by extension): com.sun.tools.javafx.script.JavaFXScriptEngineImpl@758fc9
Getting the JavaFXScriptEngine: com.sun.tools.javafx.script.JavaFXScriptEngineImpl@1113708
Running the script read from a file: java.io.BufferedReader@133f1d7
Running a built-in script
Hello World!
Returned: It works!(and it shows a Stage with a small FX script showing an animation).
Now, I try to do the same of JavaFX 1.2: same command line for compiling (except of course pointing to javafx-sdk1.2), run command is:
java -cp . -Djava.ext.dirs=%JAVAFX_HOME%/lib/shared;%JAVAFX_HOME%/lib/desktop RunJavaFXScript(more jars to take in account, I take everything...)
And when I run it I have:
Reading the E:\Dev\PhiLhoSoft\Java\_QuickExperiments\.\Test.fx script
Getting the engines
Getting the generic ScriptEngine (by extension): com.sun.tools.javafx.script.JavaFXScriptEngineImpl@8813f2
Getting the JavaFXScriptEngine: com.sun.tools.javafx.script.JavaFXScriptEngineImpl@1d58aae
Running the script read from a file: java.io.BufferedReader@83cc67
An exception has occurred in the OpenJavafx compiler. Please file a bug at the Openjfx-compiler issues home (https://openjfx-compiler.dev.java.net/Issues) after checking for duplicates. Include the following diagnostic in your report and, if possible, the source code which triggered this problem.  Thank you.
java.lang.AssertionError
        at com.sun.tools.javac.jvm.Gen.visitBreak(Gen.java:1631)
        at com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1167)
        at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:679)
        at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:714)
        at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
        at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:751)
        at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:735)
        at com.sun.tools.javac.jvm.Gen.visitSwitch(Gen.java:1210)
        at com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:943)
        at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:679)
        at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:714)
        at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:700)
        at com.sun.tools.javac.jvm.Gen.genLoop(Gen.java:1076)
        at com.sun.tools.javac.jvm.Gen.visitForLoop(Gen.java:1047)
        at com.sun.tools.javac.tree.JCTree$JCForLoop.accept(JCTree.java:856)
(and so on)So I have the same issue.
Looks like something have been broken in 1.2... :-(
Of course, the tested scripts compile without problem.
If I put only my simple built-in script in the Test.fx file, it works... I can put an empty Stage in the script (it is displayed), but if I add an empty Scene to it, I have the same error.

Similar Messages

  • How to load a code from wufoo to iweb through html

    i am trying to load a registration form from wufoo to iweb and cant figure out how to do it. I dont know where to find my html from iweb to load the code. When the code is in how do i see if it works or not. Thanks so much jacob

    When you login to wufoo you get to a page called "Form Manager"
    On this page you find the list of your Forms
    Click on "Code" near the form of interest
    Copy the code
    Go to iWeb
    Choose Web Widgets=>HTML Snippet
    (or go to Insert=>HTML Snippet)
    and paste the code in the black window that appeared
    Click on "Apply" and you form will display in iWeb.
    Regards,
    Cédric

  • Problem-Loading Byte code from DB

    Dear all,
    have any one tried to load the bytecode read from the database. If so, please suggest me a way to do it. Iam developing a frame-work where nothing except a servlet would reside on the disk as a file. after designing the frame work, i've encountered this problem...plz suggest me a way.

    Yes! You are correct. My Intention is Exactly the Same. If The byte code is residing in a database, with the classname as key, i would load all the class tree from the DB and execute the program....Please Help me
    Thanks
    Sasi

  • Parsing ANSI color codes from strings

    Hello,
    I'm putting together a telnet app/applet and the next big milestone
    on my list is putting in ANSI color support (or at least automatically
    removing it). However, I've been having trouble figuring out a way to
    read the codes.
    For anyone that doesn't know, this is an example of an ANSI code: \033
    [30m where "30" can be a number from 0 to 49.
    I've tried using a regexp to find the codes, but with my limited regexp
    knowledge, nothing has seemed to work so far. Can anyone help me out
    with this?
    Thanks.

         String test = "one\033[40mtwo\033[38mbloggle";
         System.out.println( test.replaceAll( "\\033\\[\\d\\dm", "[test]" ) );?

  • Down load source code from clas builder SE24

    Hi,
    Is it any Tcode or program to download the source code of clase with method created in SE24.
    I have to download from SAP.
    Thanks,
    sri

    Please refer:
    https://forums.sdn.sap.com/click.jspa?searchID=15176628&messageID=2863578

  • Iframe content disappear if script loaded from string

    I've got strange behaviour of FireFox 3.6-14 (have no 3.0 for now) with whis sample of code
    http://pastebin.com/CzzfB709
    Short explanation: if we create SCRIPT element and push script text from string and at the same time this script (that comes from string) create IFRAME, then iframe content is reloaded after script finished;
    In sample code you can see that we have `scriptText` variable that contains JS code. Then we create SCRIPT tag and put string code there.
    What you see: till you not close alert windows, you see text in iframe, but when you close it, iframe became blank.
    I also have an example of the same code from string if it pasted directly into HTML. Everything seems fine there.
    http://pastebin.com/4JcajiDQ
    I ask if anyone can just explain me, why is it hapend.

    As I think, this is some kind of a problem inside FireFox. So I just didn't know where to post it. Usually I'll prefer developer discussion group or maillist but I could not find such for FireFox. If you shure that mozillaZine is a best place for it than I'll wait. But I'm not shure whether it is still active community based on it's main page.

  • Load error code 11 when attempting to open .vi from library

    Hello,
    Recently a colleague sent me a .llb containing a VI and sub-VIs of a program needed for my research.  The VI opens correctly but none of the sub-VIs can be found by it and when I attempt to open the sub-VIs I get load error code 11: VI version (6.0) cannot be converted to the current Labview verstion (8.5.1) because is has no block diagram. 
    I am running Vista with 8.5.1 and attempting to open a library of version 6.0.  I do not know what OS the library was compiled on.  (Linux is a possibility)  The colleague who sent me the program does not know either, as he recieved it from another colleague whom he is no longer in contact with.
    I am fairly certain the library was saved with block diagrams, so I do not think that is the source of the error.
    Does anyone know what might be a way to get these sub-VIs working?

    Okay,
    File posted.  Someone please tell me if this has a block diagram on it.
    Attachments:
    Find First Error.vi ‏24 KB

  • Error synchroniz​ing with Windows 7 Contacts: "CRADSData​base ERROR (5211): There is an error converting Unicode string to or from code page string"

    CRADSDatabase ERROR (5211): There is an error converting Unicode string to or from code page string
    Device          Blackberry Z10
    Sw release  10.2.1.2977
    OS Version  10.2.1.3247
    The problem is known by Blackberry but they didn't make a little effort to solve this problem and they wonder why nobody buy Blackberry. I come from Android platform and I regret buying Blackberry: call problems(I sent it to service because the people that I was talking with couldn't hear me), jack problems (the headphones does not work; I will send it again to service). This synchronisation problem is "the drop that fills the glass". Please don't buy Blackberry any more.
    http://btsc.webapps.blackberry.com/btsc/viewdocume​nt.do?noCount=true&externalId=KB33098&sliceId=2&di​...

    This is a Windows registry issue, if you search the Web using these keywords:
    "how to fix craddatabase error 5211"       you will find a registry editor that syas it can fix this issue.

  • Change the mapping generation code from sql*loader to pl/sql

    I want to use a mapping with a flat file operator to generate pl/sql code even if a mapping generate sql*loader code as default.
    I tried to change the Language generation property of the mapping but an API8548 error message is shown. The suggested solution by OWB is to change the language generation code in the property inspector of the mapping.
    I can't use external table because I have to work with a remote machine.
    What i have to do to change the generation code from SQL*Loader to PL/SQL?

    How about breaking this out into 2 mappings? In the first mapping, map a flat file operator to an table using SQL*Loader code. Then define a second mapping using the table as source and therefore generate PL/SQL. Then use process flow to launch the 2nd map to run after completion of first.

  • How to updgrade to lion os 10.7 from leopard 10.6.8 using mac app store? unable to load redemption code to trigger upgrade

    how to updgrade to lion os 10.7 from leopard 10.6.8 using mac app store? unable to load redemption code to trigger upgrade.

    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Contacting Apple for support and service - this includes
    international calling numbers..
    For Mac App Store: Apple - Support - Mac App Store.
    For iTunes: Apple - Support - iTunes.

  • Labview load error code 15 preventing me from opening the VI

    I'm having some problems opening a particular VI. I get an error called: "Labview Load Error Code 15; cannot load default data." This VI cannot be opened, but I would like to somehow get into it (some important codes are in it). The Labview version is 6.1 and the system is on a Macintosh G3 with OS 8. Thanks in advance.

    It sounds like the VI is corrupt. Are you able to open it another machine or a different version of LabVIEW?

  • Invoking JavaFX script from Java

    Hi,
    Just started working on javafx and got the error below while trying to invoke javafx from java.
    /******************** my java code *************************/
    package fxexamples;
    import javax.script.Bindings;
    import javax.script.ScriptContext;
    import javax.script.ScriptEngine;
    import javax.script.ScriptEngineManager;
    import javax.script.SimpleScriptContext;
    import javax.swing.SwingUtilities;
    public class RunFX {
         public static void main(String[] args) {
              final DataObject myObj = new DataObject();
              Runnable fxScript = new Runnable() {
                   public void run() {
                        ClassLoader loader = Thread.currentThread()
                                  .getContextClassLoader();
                        ScriptEngineManager manager = new ScriptEngineManager(loader);
                        ScriptEngine engine = manager.getEngineByExtension("fx");
                        String script = "import fxexamples.FXtoJava;";
                        try {
                             engine.eval(script);
                        } catch (Exception ex) {
                             ex.printStackTrace();
              SwingUtilities.invokeLater(fxScript);
    /*****************my fx file **************************/
    import javafx.stage.Stage;
    Stage {
    title: "Die, Ajax! - Hello World"
    width: 250
    height: 50
    /*******************stack trace********************/
    javax.script.ScriptException: compilation failed
         at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.parse(JavaFXScriptEngineImpl.java:260)
         at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.eval(JavaFXScriptEngineImpl.java:149)
         at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.eval(JavaFXScriptEngineImpl.java:140)
         at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
         at fxexamples.RunFX$1.run(RunFX.java:30)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Thanks in advance.

    I too, am having problems with using JSR-223 to use JavaFX script from within Java, specifically using Java FX 1.1 and Java 6. Please see:
    http://forums.sun.com/thread.jspa?threadID=5373145

  • Error While loading a image from database

    Purpose
    Error While loading the Image from the database
    ORA-06502: PL/SQL : numeric or value error:Character string buffer too small
    ORA-06512: at "Sys.HTP" ,line 1480
    Requirement:
    I am developing the web pages using PSP(Pl/sql Serverpages) . I have a requirement to show a image in the webpage. I got the following procedures from the oracle website.
    I have created the following table to store the images
    create table DEMO
    ID INTEGER not null,
    THEBLOB BLOB
    And I also uploaded the Images. Now I am try to get a image from the table using the following procedure .But I am getting the error message line 25( htp.prn( utl_raw.cast_to_varchar2( l_raw ) );) .at it throws the following error messages
    ORA-06502: PL/SQL : numeric or value error:Character string buffer too small
    ORA-06512: at "Sys.HTP" ,line 1480
    Procedure that I used to get the image
    create or replace package body image_get
    as
    procedure gif( p_id in demo.id%type )
    is
    l_lob blob;
    l_amt number default 30;
    l_off number default 1;
    l_raw raw(4096);
    begin
    select theBlob into l_lob
    from demo
    where id = p_id;
    -- make sure to change this for your type!
    owa_util.mime_header( 'image/gif' );
    begin
    loop
    dbms_lob.read( l_lob, l_amt, l_off, l_raw );
    -- it is vital to use htp.PRN to avoid
    -- spurious line feeds getting added to your
    -- document
    htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
    l_off := l_off+l_amt;
    l_amt := 4096;
    end loop;
    exception
    when no_data_found then
    NULL;
    end;
    end;
    end;
    What I have to do to correct this problem. This demo procedure and table that I am downloaded from oracle. Some where I made a mistake. any help??
    Thanks,
    Nats

    Hi Satish,
    I have set the raw value as 3600 but still its gives the same error only. When I debug the procedure its throwing the error stack in
    SYS.htp.prn procedure of the following line of code
    if (rows_in < pack_after) then
    while ((len - loc) >= HTBUF_LEN)
    loop
    rows_in := rows_in + 1;
    htbuf(rows_in) := substr(cbuf, loc + 1, HTBUF_LEN);
    loc := loc + HTBUF_LEN;
    end loop;
    if (loc < len)
    then
    rows_in := rows_in + 1;
    htbuf(rows_in) := substr(cbuf, loc + 1);
    end if;
    return;
    end if;
    Its a system procedure. I don't no how to proceed .. I am really stucked on this....is their any other method to take picture from the database and displayed in the web page.....???? any idea..../suggesstion??
    Thanks for your help!!!.

  • Loading Textual Data from HttpService Would Not Show Up on TextArea

    Hi,
      I have something fairly strange here that I have a little problem getting it to work. I am loading some data from XML and attempt to format it a little more on Actiosncript and print it out on the TextArea. For some reason, it would not show up, even though when I used Alert.show it does spit out the entire xml data set. Based on this, I know my data has been loaded correctly, but I am not sure why it is not showing up on my page.
    Here is the code,
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:states>   
            <mx:State name="view">
              <mx:RemoveChild target="{intro}"/>
                <mx:AddChild relativeTo="{applicationcontrolbar1}" position="before">
                    <mx:TextArea editable="false" id="viewText" width="450" height="279" text="{messageInfo}"/>
                </mx:AddChild>
            </mx:State>
        </mx:states>
        <mx:Script>
            <![CDATA[
                import mx.events.ItemClickEvent;
                import mx.controls.Alert;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.events.FaultEvent;
                [Bindable]private var message:XMLList;
                [Bindable]private var messageInfo:XMLList;
                private var savedIndex:int = 99999;
       private function clickHandler(event:ItemClickEvent):void {
                    if (event.index == savedIndex) {
                        //don't do a thing
                    else {
                        savedIndex = event.index;
                          navigateToURL(new URLRequest("../"+ event.item.data));
                private function toggleButtonBar_itemClick(evt:ItemClickEvent):void {
                    currentState = evt.item.data;
                    if(evt.item.data == "view") view();
               private function view():void{
                  currentState="view";
                  userView.send();          
               private function httpService_fault(evt:FaultEvent):void {
                    var title:String = evt.type + " (" + evt.fault.faultCode + ")";
                    var text:String = evt.fault.faultString;
                    Alert.show("There is an error! Type " + title + " " + text);
               private function httpService_result(evt:ResultEvent):void {
                    messageInfo = XML(evt.result).messages.message;
                    Alert.show(messageInfo);
                    message = XML(evt.result);
                    var message_name:String = "";
                    var message_phone:String = "";
        for each (var message:XML in messageInfo.messages.message) { 
              viewText.text += "Name " + messageInfo.name + "\n";
              viewText.text += "Phone " + messageInfo.phone + "\n";               
            ]]>
        </mx:Script>
    <mx:HTTPService id="userView" url="messages.xml" resultFormat="e4x"
      fault="httpService_fault(event);" result="httpService_result(event)" />
    <mx:PhoneNumberValidator id="pnVal" source="{your_phone}" property="text"/>
    <mx:EmailValidator id="emailVal" source="{your_email}" property="text"/>
        <mx:Array id="dp">
            <mx:Object data="view" label="View"/>
        </mx:Array>
        <mx:Panel id="panel" title="My Home" height="70%">            
        <mx:TextArea id="intro" width="77%" height="100" borderStyle="none" paddingLeft="10" color="black">
                <mx:htmlText><![CDATA[Welcome to my page.]]></mx:htmlText>
            </mx:TextArea>
             <mx:ApplicationControlBar id="applicationcontrolbar1">
            <mx:ToggleButtonBar id="toggleButtonBar" color="#FFFFCC"
                    dataProvider="{dp}"
                    itemClick="toggleButtonBar_itemClick(event);" />
        </mx:ApplicationControlBar>           
        </mx:Panel> 
    </mx:Application>
    Note, there are other items in the array, but those are not relevant to the question of the topic here, and therefore I am not posting the code for those sections.
    When I click on the View button, it does give me the correct state, but I get a blank box of textArea with no data when I know there is output from Alert.show in the view(). What have I missed?
    Thanks for your help.

    Thanks for the pointer. As a matter of fact, I found out that it is because of my xml nodes messing up, and that the text was displayed as white for someb reason. With a white background, of course I would not see a thing.
    Thanks again.

  • Unable to load any XML from JAR - Please help!!

    Hi All,
    I am a student in the final days of my degree. I have been working on my final project for some time now, an applet which converts input text to a signal plot for line encoding schemes - AMI, NRZ etc. It is pretty much finished, but one small bug threatens to scuttle the entire project! I have been searching the web all day long for answers with little success, and as the castor forum still appears to be down I am posting here. Any suggestions or advice would be greatly appreciated.
    The applet uses the castor databinding framework to load various XML data. I am using Eclipse 3.01 for development - when the program is run locally as an applet, everything works fine. When the program is bundled into a JAR file and nested into a clean folder with a html page and the jar file, when the command to read in XML is given, a NullPointerException occurs, indicating that castor was unable to access the XML files.
    Below is one of the methods used to make castor load XML data:
         public CodeSet loadCodeXML(String _codesetFilename)
              String _mappingURI = "schema/codes/codesets-mapping.xml";
              String _codesetURI = "schema/codes/" + _codesetFilename;
                    // Create a new Castor mapping object
              Mapping mapping = new Mapping();                         
            try                                                                 // Attempt to load in the selected XML character set
                 mapping.loadMapping(_mappingURI);                    // Initialize 'mapping' with the map file
                Unmarshaller unmar = new Unmarshaller(mapping); // Create a new XML Unmarshaller that uses 'mapping'
                // The line below creates a new CharSet object called _codeset and populates it with the XML data
                CodeSet _codeset = (CodeSet)unmar.unmarshal(new InputSource(new FileReader(_codesetURI)));
                // The character set was successfully loaded, so pass new CharSet object back to caller and end
                return _codeset;
            } catch (Exception e) {
                 // If an error occurs while extracting the XML data, this block will execute:
                JOptionPane.showMessageDialog(null, e);               // Display a message dialog containing the exception error
                return null;                                             // Do not return a CharSet object to caller
         }It would seem to me the problem lies within
              String _mappingURI = "schema/codes/codesets-mapping.xml";
              String _codesetURI = "schema/codes/" + _codesetFilename;I have read that files inside a JAR can be accessed in this way ( http://archive.codehaus.org/castor/user/msg00025.html ) but it won't appear to work.
    If these are set to a full system path (outside any JAR) i.e. "/home/me/proj/schema/codes/codesets-mapping.xml", the application operates fine. Clearly this is no good however, as the XML data must reside within the JAR package. I have tried many permutations such as "jar://schema/..." , "/schema/..", "schema/..", with no success. I have read of using InputStream and getResource methods to access files within the jar but have had no success. I have checked the schema dir is being put into the JAR archive.
    Could anyone suggest an appropriate way of loading XML files from within a JAR file in this context?
    Thanks in advance for any replies.

    Hi, me again..
    Re: mr_doghead - the filename of the file is passed from the calling function
    public CodeSet loadCodeXML(String _codesetFilename)eg loadCodeXML(ami.xml) will return a CodeSet object containing the ami xml data
    Anyway, I've manged to fix it up. The problem actually lies within castor, not my code at all. This is a known bug in castor that the dev's deemed 'not important' to fix, but I have to say the work around is EXTREMLY poorly documented online. Hence, this post is just to say how to fix it up if ne1 else is having trouble...
    To load mappings, use:
    mapping.loadMapping(getClass().getResource(_mappingURI).toString());where _mappingURI is a string such as "/xml/mapfile.xml"
    However, the unmarshalling method takes in a file object, so getResourceAsStream must be used:
    CharSet _charset = (CharSet)unmar.unmarshal(new InputSource(getClass().getResourceAsStream(_charsetURI)));Where CharSet is your custom object you are marshalling into, and _charsetURI is a relative path to your xml file.
    Ugly as hell? Very.
    Does it work? Perfectly.
    take it ez guys, time for me to go hand this sht in! ;D

Maybe you are looking for