Re: [jnc-users] SWT compile
Status: Beta
Brought to you by:
soapy
From: Marco T. <mt...@gm...> - 2007-02-17 11:43:18
|
Lee D. Painter wrote: > Thanks for your help Marco it's much appreciated, and it's now linking > :) I just need to sort out the image handlers as per your docs. I add this file to the compilation: http://javacompiler.svn.sourceforge.net/viewvc/javacompiler/trunk/src/org/eclipse/swt/internal/image/ImagePullin.java?view=markup Marco > Keep up the good work. > > Lee > >> -----Original Message----- >> From: Marco Trudel [mailto:mt...@gm...] >> Sent: 17 February 2007 10:00 >> To: Lee D. Painter >> Cc: A mailing list for general questions and discussions. >> Subject: Re: [jnc-users] SWT compile >> >> Please do not top post... >> >> >> Lee D. Painter wrote: >>> Hi Marco, >>> >>> I read Step 1 of the manual regarding the image handlers but did not > see >>> the FAQ reference about this error. >> I meant "Why do I get 'multiple definitions of ...' errors when >> excluding the GUI or JCE?": >> http://jnc.mtsystems.ch/frame_faq.html#multipleDefinitions >> >> >>> Is it enough to remove the >>> org.eclipse.swt.awt package from the swt.jar or is there a better > way? >> Yes, that would suffice. But I suggest to uncheck the checkbox in the >> GUI when adding the jar, then only referenced classes from swt.jar > would >> be pulled in (thus leaving out org.eclipse.swt.awt.* and also result > in >> a smaller binary). >> >> >>> Perhaps you already did this for JNC? >> Yes, check the screenshots on the homepage. They show how I compile > JNC >> with JNC ;-) You'll see that the checkbox for swt.jar is not checked > and >> thus org.eclipse.swt.awt.* won't be pulled in. >> >> >> Marco >> >>> Regards >>> >>> Lee >>> >>> PS: Yes I'm on the list. >>> >>>> -----Original Message----- >>>> From: jav...@li... >>>> [mailto:jav...@li...] On Behalf > Of >>>> Marco Trudel >>>> Sent: 17 February 2007 08:42 >>>> To: A mailing list for general questions and discussions. >>>> Subject: Re: [jnc-users] SWT compile >>>> >>>> Lee D. Painter wrote: >>>>> Hi Marco, >>>>> >>>>> I had previously had problems with an AWT compile, which after > your >>> help >>>>> I was able to get working. The corrupted GIF image issue however >>> meant >>>> I released a new version of JNC (1.1) which fixes GIFs. But it > seems >>> the >>>> new GCC version has introduced new trouble with AWT/Swing. I'm on > it. >>>> So I still recommend to use SWT whenever possible (it will compile >>>> flawlessly, binaries will be smaller and the UI looks better). >>>> >>>> >>>>> that we cannot use the compiled .exe so we decided to add an SWT > GUI >>> to >>>>> our agent, which honestly looks much better but I'm now seeing >>> errors >>>>> when attempting to build this. >>>>> >>>>> A search in our source code shows no trace of AWT or Swing, and > the >>>>> compile completes with the exclude GUI option. The problem lies in >>>>> linking; here are some the errors I'm seeing. Any advice would be >>> very >>>>> much appreciated. >>>>> >>>>> I'm trying to build Windows .exe on Windows with gcc-119844-win. >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- > mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ >>>>> 0x20): multiple definition of >>>>> `java::awt::AWTPermission::AWTPermission(java::lang::String*)' >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- >>>>> mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x290): > first >>>>> defined here >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- > mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ >>>>> 0xaa0): multiple definition of >>>>> `java::awt::Button::Button(java::lang::String*)' >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- >>>>> mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x2d0): > first >>>>> defined here >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- > mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ >>>>> 0xc8f0): multiple definition of >>>>> `java::awt::GridBagConstraints::GridBagConstraints(int, int, int, >>> int, >>>>> double, double, int, int, java::awt::Insets*, int, int)' >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- >>>>> mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x150): > first >>>>> defined here >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- > mingw32/4.2.0/../../../libgcj.a(gui_java_awt.o):gui_java_awt.zip:(.text+ >>>>> 0xca70): multiple definition of >>>>> `java::awt::GridBagLayout::GridBagLayout()' >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- >>>>> mingw32/4.2.0/../../../libjncNoGui.a:noGui.jar:(.text+0x130): > first >>>>> defined here >>>>> >>>>> > c:/tools/javanativecompiler-1.0.1/gcc-119844-win/bin/../lib/gcc/i686-pc- >>>> This is explained in the FAQ and in the manual. The problem is that >>> SWT >>>> uses AWT for the "org.eclipse.swt.awt" package. I assume you > compile >>> the >>>> complete swt.jar into your binary. Thus you need AWT what of course >>>> unnecessary enlarges the binary. >>>> The solution here is to only import referenced classes from > swt.jar. >>>> That will omit the "org.eclipse.swt.awt" package and additionally > have >>>> the advantage of create a smaller binary. >>>> But please read the manual topic "Step 1 of 4: Source" since it > will >>>> create new difficulties you have to consider. It's just a 10 lines >>>> description, so you won't have to spend a lot of time reading it > :-) >>>> >>>> Marco >>>> >>>>> Regards >>>>> >>>>> Lee >>>>>> -----Original Message----- >>>>>> From: jav...@li... >>>>>> [mailto:jav...@li...] On > Behalf >>> Of >>>>>> Marco Trudel >>>>>> Sent: 15 February 2007 08:02 >>>>>> To: Steven Blade; A mailing list for general questions and >>>>> discussions. >>>>>> Subject: Re: [jnc-users] [javaCompiler-users] compiles and > executes >>>>> but >>>>>> throws java exception --help >>>>>> >>>>>> Please always do "reply all", else we loose the mailinglist... >>>>>> >>>>>> >>>>>> Steven Blade wrote: >>>>>>> ok sure thing but please show me where to use the static block > of >>>>> code >>>>>> ok. >>>>>> >>>>>> Thanks for the sample. Just put that code in an own class (as the >>>>>> attached XmlLoader.java) and add this class to the JNC > compilation >>>>>> source. This will ensure that the needed objects are pulled into >>> the >>>>>> binary. >>>>>> You do not have to change your source. >>>>>> >>>>>> >>>>>>> did it work both ways with you reading and transforming xml ? >>>>>> Reading works, writing (transforming) fails. I'll create a >>> bugreport >>>>>> (it's probably a GNU classpath bug) and hope that the fix will be >>> in >>>>> JNC >>>>>> 1.2. >>>>>> >>>>>>> one more thing does that mean i have to use gnu's jar instead of >>>>> java's >>>>>> ? >>>>>> >>>>>> No, you only have to ensure that your binary contains the xml >>> stuff. >>>>>> This is done with the static initializer since it references the >>> xml >>>>>> stuff and thus ld - the linker - will add them. >>>>>> >>>>>> >>>>>> Marco >>>>>> >>>>>> >>>>>>> import java.io.BufferedReader; >>>>>>> import java.io.File; >>>>>>> import java.io.InputStreamReader; >>>>>>> >>>>>>> import javax.xml.parsers.SAXParser; >>>>>>> import javax.xml.parsers.SAXParserFactory; >>>>>>> import javax.xml.transform.OutputKeys; >>>>>>> import javax.xml.transform.Transformer; >>>>>>> import javax.xml.transform.sax.SAXTransformerFactory; >>>>>>> import javax.xml.transform.sax.TransformerHandler; >>>>>>> import javax.xml.transform.stream.StreamResult; >>>>>>> >>>>>>> import org.xml.sax.Attributes; >>>>>>> import org.xml.sax.SAXException; >>>>>>> import org.xml.sax.helpers.AttributesImpl; >>>>>>> import org.xml.sax.helpers.DefaultHandler; >>>>>>> >>>>>>> >>>>>>> public class Foo extends DefaultHandler{ >>>>>>> >>>>>>> /** >>>>>>> * @param args >>>>>>> */ >>>>>>> private static File file; >>>>>>> private static String contents; >>>>>>> private static Foo f=new Foo(); >>>>>>> public static void main(String[] args) { >>>>>>> // TODO Auto-generated method stub >>>>>>> System.out.print("enter location of xml file to > read "); >>>>>>> BufferedReader input=new BufferedReader(new >>>>>> InputStreamReader(System.in)); >>>>>>> try >>>>>>> { >>>>>>> String sfile=input.readLine(); >>>>>>> file=new File(sfile); >>>>>>> readXml(); >>>>>>> System.out.print(contents); >>>>>>> writeXml(); >>>>>>> }catch(Exception _){_.printStackTrace();} >>>>>>> } >>>>>>> private static void writeXml() >>>>>>> { >>>>>>> SAXTransformerFactory > factory=(SAXTransformerFactory)SAXTransformerFactory.newInstance(); >>>>>>> try{ >>>>>>> StreamResult stream=new StreamResult(System.out); >>>>>>> TransformerHandler >> handler=factory.newTransformerHandler(); >>>>>>> Transformer trans=handler.getTransformer(); >>>>>>> trans.setOutputProperty > (OutputKeys.ENCODING,"ISO-8859-1"); >>>>>>> trans.setOutputProperty(OutputKeys.INDENT,"yes"); >>>>>>> handler.setResult(stream); >>>>>>> handler.startDocument(); >>>>>>> AttributesImpl atts=new AttributesImpl(); >>>>>>> handler.startElement("", "", "test", atts); >>>>>>> atts.clear(); >>>>>>> handler.startElement("", "", "foo", atts); >>>>>>> handler.characters(new char[]{'a','b','c'}, 0, 3); >>>>>>> handler.endElement("", "", "foo"); >>>>>>> handler.endElement("", "", "test"); >>>>>>> handler.endDocument(); >>>>>>> }catch(Exception _){_.printStackTrace();} >>>>>>> } >>>>>>> >>>>>>> private static void readXml() >>>>>>> { >>>>>>> System.out.println("reading xml..."); >>>>>>> try{ >>>>>>> SAXParserFactory > factory=SAXParserFactory.newInstance(); // >>>>> the >>>>>> exception points to this line >>>>>>> factory.setValidating(false); >>>>>>> SAXParser parser=factory.newSAXParser(); >>>>>>> parser.parse (file, f.new OwnHandler()); >>>>>>> } >>>>>>> catch(Exception _){_.printStackTrace();} >>>>>>> } >>>>>>> >>>>>>> private class OwnHandler extends DefaultHandler{ >>>>>>> >>>>>>> public void startElement(String namespaceURI, >>>>>>> String sName, >>>>>>> String qName, >>>>>>> Attributes attrs) throws > SAXException{ >>>>>>> contents+="<"+qName+">"; >>>>>>> } >>>>>>> public void endElement(String uri, String localName, > String >>>>> qName) >>>>>> throws SAXException{ >>>>>>> contents+="<"+qName+"/>"; >>>>>>> } >>>>>>> public void characters(char[] buf,int offset,int >> length)throws >>>>>> SAXException{ >>>>>>> contents+=new String(buf,offset,length); >>>>>>> } >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> > ------------------------------------------------------------------------ >>>>>>> <?xml version=1.0 encoding=UTF-8?> >>>>>>> <test> >>>>>>> <line>testing java native compiler</line> >>>>>>> </test> >>>>> > ------------------------------------------------------------------------ >>>> - >>>>> Take Surveys. Earn Cash. Influence the Future of IT >>>>> Join SourceForge.net's Techsay panel and you'll get the chance to >>> share >>>> your >>>>> opinions on IT & business topics through brief surveys-and earn > cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE >>> V >>>>> _______________________________________________ >>>>> javaCompiler-users mailing list >>>>> jav...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/javacompiler-users >>>>> >>>> > ------------------------------------------------------------------------ >>> - >>>> Take Surveys. Earn Cash. Influence the Future of IT >>>> Join SourceForge.net's Techsay panel and you'll get the chance to >>> share >>>> your >>>> opinions on IT & business topics through brief surveys-and earn > cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE >>> V >>>> _______________________________________________ >>>> javaCompiler-users mailing list >>>> jav...@li... >>>> https://lists.sourceforge.net/lists/listinfo/javacompiler-users > |