Thread: Re: [jnc-users] SWT compile
Status: Beta
Brought to you by:
soapy
From: Lee D. P. <le...@3s...> - 2007-02-17 09:53:11
|
Hi Marco, I read Step 1 of the manual regarding the image handlers but did not see the FAQ reference about this error. Is it enough to remove the org.eclipse.swt.awt package from the swt.jar or is there a better way? Perhaps you already did this for JNC?=20 Regards Lee PS: Yes I'm on the list.=20 > -----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 >=20 > 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 >=20 > 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). >=20 >=20 > > 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- >=20 > 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 :-) >=20 >=20 > Marco >=20 > > 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=3Dnew Foo(); > >>> public static void main(String[] args) { > >>> // TODO Auto-generated method stub > >>> System.out.print("enter location of xml file to read "); > >>> BufferedReader input=3Dnew BufferedReader(new > >> InputStreamReader(System.in)); > >>> try > >>> { > >>> String sfile=3Dinput.readLine(); > >>> file=3Dnew File(sfile); > >>> readXml(); > >>> System.out.print(contents); > >>> writeXml(); > >>> }catch(Exception _){_.printStackTrace();} > >>> } > >>> private static void writeXml() > >>> { > >>> SAXTransformerFactory > >> = factory=3D(SAXTransformerFactory)SAXTransformerFactory.newInstance(); > >>> try{ > >>> StreamResult stream=3Dnew StreamResult(System.out); > >>> TransformerHandler handler=3Dfactory.newTransformerHandler(); > >>> Transformer trans=3Dhandler.getTransformer(); > >>> trans.setOutputProperty (OutputKeys.ENCODING,"ISO-8859-1"); > >>> trans.setOutputProperty(OutputKeys.INDENT,"yes"); > >>> handler.setResult(stream); > >>> handler.startDocument(); > >>> AttributesImpl atts=3Dnew 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=3DSAXParserFactory.newInstance(); // > > the > >> exception points to this line > >>> factory.setValidating(false); > >>> SAXParser parser=3Dfactory.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+=3D"<"+qName+">"; > >>> } > >>> public void endElement(String uri, String localName, String > > qName) > >> throws SAXException{ > >>> contents+=3D"<"+qName+"/>"; > >>> } > >>> public void characters(char[] buf,int offset,int length)throws > >> SAXException{ > >>> contents+=3Dnew String(buf,offset,length); > >>> } > >>> } > >>> } > >>> > >>> > >>> > >>> > >>> > > ------------------------------------------------------------------------ > >>> <?xml version=3D1.0 encoding=3DUTF-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=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE V > > _______________________________________________ > > javaCompiler-users mailing list > > jav...@li... > > https://lists.sourceforge.net/lists/listinfo/javacompiler-users > > >=20 >=20 > ------------------------------------------------------------------------ - > 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=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE V > _______________________________________________ > javaCompiler-users mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/javacompiler-users |
From: Lee D. P. <le...@3s...> - 2007-02-17 10:10:05
|
>=20 > Please do not top post... Hmmm ok as you wish.=20 =20 >=20 > 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. >=20 > I meant "Why do I get 'multiple definitions of ...' errors when > excluding the GUI or JCE?": > http://jnc.mtsystems.ch/frame_faq.html#multipleDefinitions Yes I understood that, I was just explaining that I did not see the FAQ nor the reference to the multiple definitions error until you pointed that out :-) >=20 > > Is it enough to remove the > > org.eclipse.swt.awt package from the swt.jar or is there a better way? >=20 > 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). >=20 Ok, I had misunderstood setting. =20 > > Perhaps you already did this for JNC? >=20 > 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. >=20 >=20 > Marco >=20 > > > > 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=3Dnew Foo(); > >>>>> public static void main(String[] args) { > >>>>> // TODO Auto-generated method stub > >>>>> System.out.print("enter location of xml file to read "); > >>>>> BufferedReader input=3Dnew BufferedReader(new > >>>> InputStreamReader(System.in)); > >>>>> try > >>>>> { > >>>>> String sfile=3Dinput.readLine(); > >>>>> file=3Dnew File(sfile); > >>>>> readXml(); > >>>>> System.out.print(contents); > >>>>> writeXml(); > >>>>> }catch(Exception _){_.printStackTrace();} > >>>>> } > >>>>> private static void writeXml() > >>>>> { > >>>>> SAXTransformerFactory > >>>> factory=3D(SAXTransformerFactory)SAXTransformerFactory.newInstance(); > >>>>> try{ > >>>>> StreamResult stream=3Dnew StreamResult(System.out); > >>>>> TransformerHandler > handler=3Dfactory.newTransformerHandler(); > >>>>> Transformer trans=3Dhandler.getTransformer(); > >>>>> trans.setOutputProperty (OutputKeys.ENCODING,"ISO-8859-1"); > >>>>> trans.setOutputProperty(OutputKeys.INDENT,"yes"); > >>>>> handler.setResult(stream); > >>>>> handler.startDocument(); > >>>>> AttributesImpl atts=3Dnew 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=3DSAXParserFactory.newInstance(); // > >>> the > >>>> exception points to this line > >>>>> factory.setValidating(false); > >>>>> SAXParser parser=3Dfactory.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+=3D"<"+qName+">"; > >>>>> } > >>>>> public void endElement(String uri, String localName, String > >>> qName) > >>>> throws SAXException{ > >>>>> contents+=3D"<"+qName+"/>"; > >>>>> } > >>>>> public void characters(char[] buf,int offset,int > length)throws > >>>> SAXException{ > >>>>> contents+=3Dnew String(buf,offset,length); > >>>>> } > >>>>> } > >>>>> } > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > > ------------------------------------------------------------------------ > >>>>> <?xml version=3D1.0 encoding=3DUTF-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=3Djoin.php&p=3Dsourceforge&CID=3D= 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=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE > > V > >> _______________________________________________ > >> javaCompiler-users mailing list > >> jav...@li... > >> https://lists.sourceforge.net/lists/listinfo/javacompiler-users > > |
From: Marco T. <mt...@gm...> - 2007-02-17 11:40:50
|
Lee D. Painter wrote: >> Please do not top post... > > Hmmm ok as you wish. Just in case you misunderstood that or feel offended: This is not to terrorize you, it is just a rule for using mailinglists because this is the only productive way of getting fast into the picture. For instance, I get a couple of dozens mails every day. I mostly don't know about the current discussion state. So it is a great time-saver if I can read the lines above the question to get into the picture again. Otherwise I had to always read the whole email what would really suck... So, usually, you help the people which try to help you when obeying the general unwritten(?) rules and people will tell you if you don't. In very worse case, your mail might just be ignored because it's inconvenient to read. thanks Marco >> 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 > > Yes I understood that, I was just explaining that I did not see the FAQ > nor the reference to the multiple definitions error until you pointed > that out :-) > >>> 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). >> > > Ok, I had misunderstood setting. > >>> 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 > |
From: Lee D. P. <le...@3s...> - 2007-02-17 11:08:44
|
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.=20 Keep up the good work.=20 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 >=20 > Please do not top post... >=20 >=20 > 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. >=20 > I meant "Why do I get 'multiple definitions of ...' errors when > excluding the GUI or JCE?": > http://jnc.mtsystems.ch/frame_faq.html#multipleDefinitions >=20 >=20 > > Is it enough to remove the > > org.eclipse.swt.awt package from the swt.jar or is there a better way? >=20 > 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). >=20 >=20 > > Perhaps you already did this for JNC? >=20 > 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. >=20 >=20 > Marco >=20 > > > > 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=3Dnew Foo(); > >>>>> public static void main(String[] args) { > >>>>> // TODO Auto-generated method stub > >>>>> System.out.print("enter location of xml file to read "); > >>>>> BufferedReader input=3Dnew BufferedReader(new > >>>> InputStreamReader(System.in)); > >>>>> try > >>>>> { > >>>>> String sfile=3Dinput.readLine(); > >>>>> file=3Dnew File(sfile); > >>>>> readXml(); > >>>>> System.out.print(contents); > >>>>> writeXml(); > >>>>> }catch(Exception _){_.printStackTrace();} > >>>>> } > >>>>> private static void writeXml() > >>>>> { > >>>>> SAXTransformerFactory > >>>> factory=3D(SAXTransformerFactory)SAXTransformerFactory.newInstance(); > >>>>> try{ > >>>>> StreamResult stream=3Dnew StreamResult(System.out); > >>>>> TransformerHandler > handler=3Dfactory.newTransformerHandler(); > >>>>> Transformer trans=3Dhandler.getTransformer(); > >>>>> trans.setOutputProperty (OutputKeys.ENCODING,"ISO-8859-1"); > >>>>> trans.setOutputProperty(OutputKeys.INDENT,"yes"); > >>>>> handler.setResult(stream); > >>>>> handler.startDocument(); > >>>>> AttributesImpl atts=3Dnew 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=3DSAXParserFactory.newInstance(); // > >>> the > >>>> exception points to this line > >>>>> factory.setValidating(false); > >>>>> SAXParser parser=3Dfactory.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+=3D"<"+qName+">"; > >>>>> } > >>>>> public void endElement(String uri, String localName, String > >>> qName) > >>>> throws SAXException{ > >>>>> contents+=3D"<"+qName+"/>"; > >>>>> } > >>>>> public void characters(char[] buf,int offset,int > length)throws > >>>> SAXException{ > >>>>> contents+=3Dnew String(buf,offset,length); > >>>>> } > >>>>> } > >>>>> } > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > > ------------------------------------------------------------------------ > >>>>> <?xml version=3D1.0 encoding=3DUTF-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=3Djoin.php&p=3Dsourceforge&CID=3D= 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=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE > > V > >> _______________________________________________ > >> javaCompiler-users mailing list > >> jav...@li... > >> https://lists.sourceforge.net/lists/listinfo/javacompiler-users > > |
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 > |
From: Lee D. P. <le...@3s...> - 2007-02-17 13:00:05
|
I certainly didn't feel offended just a bit surprised that's all. I've been involved with my own open source projects for the past few years and have been in a similar position with regard to email from mailing lists but have never come across that breed of netiquette before. I guess I would just go with the flow, but everyone is entitled to their opinion and if that's how you want it I'm certainly not going to argue or be offended. :) > -----Original Message----- > From: Marco Trudel [mailto:mt...@gm...] > Sent: 17 February 2007 11:41 > To: Lee D. Painter > Cc: A mailing list for general questions and discussions. > Subject: Re: [jnc-users] SWT compile >=20 > Lee D. Painter wrote: > >> Please do not top post... > > > > Hmmm ok as you wish. >=20 > Just in case you misunderstood that or feel offended: > This is not to terrorize you, it is just a rule for using mailinglists > because this is the only productive way of getting fast into the > picture. For instance, I get a couple of dozens mails every day. I > mostly don't know about the current discussion state. So it is a great > time-saver if I can read the lines above the question to get into the > picture again. Otherwise I had to always read the whole email what would > really suck... > So, usually, you help the people which try to help you when obeying the > general unwritten(?) rules and people will tell you if you don't. In > very worse case, your mail might just be ignored because it's > inconvenient to read. >=20 >=20 > thanks > Marco >=20 >=20 > >> 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 > > > > Yes I understood that, I was just explaining that I did not see the FAQ > > nor the reference to the multiple definitions error until you pointed > > that out :-) > > > >>> 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). > >> > > > > Ok, I had misunderstood setting. > > > >>> 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=3Dnew Foo(); > >>>>>>> public static void main(String[] args) { > >>>>>>> // TODO Auto-generated method stub > >>>>>>> System.out.print("enter location of xml file to > > read "); > >>>>>>> BufferedReader input=3Dnew BufferedReader(new > >>>>>> InputStreamReader(System.in)); > >>>>>>> try > >>>>>>> { > >>>>>>> String sfile=3Dinput.readLine(); > >>>>>>> file=3Dnew File(sfile); > >>>>>>> readXml(); > >>>>>>> System.out.print(contents); > >>>>>>> writeXml(); > >>>>>>> }catch(Exception _){_.printStackTrace();} > >>>>>>> } > >>>>>>> private static void writeXml() > >>>>>>> { > >>>>>>> SAXTransformerFactory > > = factory=3D(SAXTransformerFactory)SAXTransformerFactory.newInstance(); > >>>>>>> try{ > >>>>>>> StreamResult stream=3Dnew StreamResult(System.out); > >>>>>>> TransformerHandler > >> handler=3Dfactory.newTransformerHandler(); > >>>>>>> Transformer trans=3Dhandler.getTransformer(); > >>>>>>> trans.setOutputProperty > > (OutputKeys.ENCODING,"ISO-8859-1"); > >>>>>>> trans.setOutputProperty(OutputKeys.INDENT,"yes"); > >>>>>>> handler.setResult(stream); > >>>>>>> handler.startDocument(); > >>>>>>> AttributesImpl atts=3Dnew 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=3DSAXParserFactory.newInstance(); // > >>>>> the > >>>>>> exception points to this line > >>>>>>> factory.setValidating(false); > >>>>>>> SAXParser parser=3Dfactory.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+=3D"<"+qName+">"; > >>>>>>> } > >>>>>>> public void endElement(String uri, String localName, > > String > >>>>> qName) > >>>>>> throws SAXException{ > >>>>>>> contents+=3D"<"+qName+"/>"; > >>>>>>> } > >>>>>>> public void characters(char[] buf,int offset,int > >> length)throws > >>>>>> SAXException{ > >>>>>>> contents+=3Dnew String(buf,offset,length); > >>>>>>> } > >>>>>>> } > >>>>>>> } > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > > ------------------------------------------------------------------------ > >>>>>>> <?xml version=3D1.0 encoding=3DUTF-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=3Djoin.php&p=3Dsourceforge&CID=3D= 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=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE > >>> V > >>>> _______________________________________________ > >>>> javaCompiler-users mailing list > >>>> jav...@li... > >>>> https://lists.sourceforge.net/lists/listinfo/javacompiler-users > > |
From: Marco T. <mt...@gm...> - 2007-02-18 10:11:37
|
Lee D. Painter wrote: > I certainly didn't feel offended just a bit surprised that's all. I've > been involved with my own open source projects for the past few years > and have been in a similar position with regard to email from mailing > lists but have never come across that breed of netiquette before. Well, I suppose it really depends on the community you're in and the traffic that is generated there. I think all major and most minor lists I used so far used inline replying. So I got used to it. > I guess I would just go with the flow, but everyone is entitled to their > opinion and if that's how you want it I'm certainly not going to argue > or be offended. thanks :-) Marco |
From: Marco T. <mt...@gm...> - 2007-02-17 10:00:39
|
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 > |