public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* java.lang.NoClassDefFoundError: java.text.DecimalFormat
@ 2009-11-30 15:39 Keith Boynton
  2009-11-30 15:45 ` Andrew Haley
  2009-11-30 18:29 ` Ben Gardiner
  0 siblings, 2 replies; 10+ messages in thread
From: Keith Boynton @ 2009-11-30 15:39 UTC (permalink / raw)
  To: java

Hi folks,

I'm pretty new to GCJ, however I have been making good progress. I've 
managed to resolve quite a few issues.

I have reached a problem I'm really struggling to resolve though.

I'm successfully compiling my project and have managed to resolve quite a 
few "NoClassDefFoundError"s, by various methods.

However the fix for this one is really eluding me...

Exception in thread "main" java.lang.NoClassDefFoundError: 
java.text.DecimalFormat
   at gnu.xml.transform.Stylesheet.initDefaultDecimalFormat

I have the following in my code to try and force linking...

private static final Class class3 = java.text.DecimalFormat.class;
static { java.text.DecimalFormat.class.getName(); }

I have a version of rt.jar that I know definitely contains 
java/text/DecimalFormat.class that is being compiled.

I'm using the following flags:
-Wl,--allow-multiple-definition
-findirect-dispatch

Can anyone give me a few pointers as to what I need to do to get this class 
included in my binary?


Thanks in advance

Keith 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-11-30 15:39 java.lang.NoClassDefFoundError: java.text.DecimalFormat Keith Boynton
@ 2009-11-30 15:45 ` Andrew Haley
  2009-11-30 21:13   ` Keith Boynton
  2009-11-30 18:29 ` Ben Gardiner
  1 sibling, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2009-11-30 15:45 UTC (permalink / raw)
  To: Keith Boynton; +Cc: java

Keith Boynton wrote:

> I'm pretty new to GCJ, however I have been making good progress. I've 
> managed to resolve quite a few issues.
> 
> I have reached a problem I'm really struggling to resolve though.
> 
> I'm successfully compiling my project and have managed to resolve quite a 
> few "NoClassDefFoundError"s, by various methods.
> 
> However the fix for this one is really eluding me...
> 
> Exception in thread "main" java.lang.NoClassDefFoundError: 
> java.text.DecimalFormat
>    at gnu.xml.transform.Stylesheet.initDefaultDecimalFormat
> 
> I have the following in my code to try and force linking...
> 
> private static final Class class3 = java.text.DecimalFormat.class;
> static { java.text.DecimalFormat.class.getName(); }
> 
> I have a version of rt.jar that I know definitely contains 
> java/text/DecimalFormat.class that is being compiled.

gcj will only use its own rt.jar.

> I'm using the following flags:
> -Wl,--allow-multiple-definition
> -findirect-dispatch
> 
> Can anyone give me a few pointers as to what I need to do to get this class 
> included in my binary?

We will help you, but you must tell us which gcj release you're using
and you really should provide a short (but complete, compilable) test
case that shows the problem.

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-11-30 15:39 java.lang.NoClassDefFoundError: java.text.DecimalFormat Keith Boynton
  2009-11-30 15:45 ` Andrew Haley
@ 2009-11-30 18:29 ` Ben Gardiner
  2009-11-30 18:33   ` Andrew Haley
  1 sibling, 1 reply; 10+ messages in thread
From: Ben Gardiner @ 2009-11-30 18:29 UTC (permalink / raw)
  To: Keith Boynton; +Cc: java

Keith Boynton wrote:
> I have reached a problem I'm really struggling to resolve though.
>
> I'm successfully compiling my project and have managed to resolve 
> quite a few "NoClassDefFoundError"s, by various methods.
>
> However the fix for this one is really eluding me...
>
> Exception in thread "main" java.lang.NoClassDefFoundError: 
> java.text.DecimalFormat
>   at gnu.xml.transform.Stylesheet.initDefaultDecimalFormat
This sounds very similar to the problem addressed in a previous thread: 
http://old.nabble.com/SimpleDateFormat-td18000139.html. Perhaps the 
solution is also similar:

from that thread:
> #copy libgcj to a working dir (could be in a different location than
> /usr/lib/ for you)
> mkdir -p /tmp/mess_with_libgcj
> cd /tmp/mess_with_libgcj
> cp /usr/lib/libgcj.a .
>
> #extract all the object from this library
> ar x libgcj.a
>
> #make a lib with only the properties objects
> ar rvcs libgcj_properties.a *properties*.o
> #do the (sometimes superfluous) blessing of the lib
> ranlib libgcj_properties.a
>
> #copy the lib to the system lib dir
> cp libgcj_properties.a /usr/lib/
>
>
> #goto your source project and this time link-in those properties objects
> with --whole-archive, this forces the linker to include them even if
> they aren't statically referenced
> cd <your source build-tree>
> *gcj* -o <your prog> -Wl,--whole-archive -lgcj_properties
> -Wl,--no-whole-archive -static-libgcj --main=<your main> 
I hope this helps,
Ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-11-30 18:29 ` Ben Gardiner
@ 2009-11-30 18:33   ` Andrew Haley
  2009-11-30 21:13     ` Keith Boynton
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2009-11-30 18:33 UTC (permalink / raw)
  To: Ben Gardiner; +Cc: Keith Boynton, java

Ben Gardiner wrote:
> Keith Boynton wrote:
>> I have reached a problem I'm really struggling to resolve though.
>>
>> I'm successfully compiling my project and have managed to resolve 
>> quite a few "NoClassDefFoundError"s, by various methods.
>>
>> However the fix for this one is really eluding me...
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError: 
>> java.text.DecimalFormat
>>   at gnu.xml.transform.Stylesheet.initDefaultDecimalFormat
> This sounds very similar to the problem addressed in a previous thread: 
> http://old.nabble.com/SimpleDateFormat-td18000139.html. Perhaps the 
> solution is also similar:

Yes, well spotted.  The OP didn't mention Windows, though.

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-11-30 18:33   ` Andrew Haley
@ 2009-11-30 21:13     ` Keith Boynton
  0 siblings, 0 replies; 10+ messages in thread
From: Keith Boynton @ 2009-11-30 21:13 UTC (permalink / raw)
  To: Andrew Haley, Ben Gardiner; +Cc: java

Guys I really appreciate this, I'll do some testing with this it looks very 
relevant!

Yes it is indeed Windows.

Thanks again 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-11-30 15:45 ` Andrew Haley
@ 2009-11-30 21:13   ` Keith Boynton
  2009-11-30 21:15     ` Ben Gardiner
  0 siblings, 1 reply; 10+ messages in thread
From: Keith Boynton @ 2009-11-30 21:13 UTC (permalink / raw)
  To: Andrew Haley; +Cc: java

I do apologise for the lack of information I provided.

I'm using the latest version of the JavaNativeCompiler which (as I'm sure 
you aware) is a front end to GCJ 4.3.

The OS is indeed Windows.

Here is a short test case that does reproduce the error.


import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;

public class Test {
	public static void main(String[] args) {
		try {
			TransformerFactory tFactory = TransformerFactory.newInstance();
			Transformer objXSLT = tFactory.newTransformer(new 
javax.xml.transform.stream.StreamSource("c:\\some.xsl"));
		} catch (Exception objException) {
		}
	}
}

Command generated by JavaNativeCompiler:
gcc-122233-win\bin\gcj
		--main=Test
		-fjni
		-Djava.library.path=lib
		-Dsun.java2d.fontpath=
		-Djava.home=.
		-Djava.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
		-Dawt.toolkit=sun.awt.windows.WToolkit
		-Dsun.io.unicode.encoding=UnicodeLittle
		-Llibs/win
		-Ilibs/win/gui/gui.jar
		-oC:\JavaNativeCompiler-1.1.1\compiled\test.exe
		-s
		-O2
		c:\temp\templib\*
		-findirect-dispatch
		-ljncTrial
		-IC:\\EclipseWorkspace\Test\src
		@C:\Temp\JNCTempaoljps.out\SourceListaoljpt.list

It's worth noting that c:\temp\templib contains the .o files extracted from 
libgcj.a using ar.exe x libgcj.a

Keith 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-11-30 21:13   ` Keith Boynton
@ 2009-11-30 21:15     ` Ben Gardiner
  2009-12-04  8:34       ` Keith Boynton
  0 siblings, 1 reply; 10+ messages in thread
From: Ben Gardiner @ 2009-11-30 21:15 UTC (permalink / raw)
  To: Keith Boynton; +Cc: Andrew Haley, java

Keith Boynton wrote:
> Command generated by JavaNativeCompiler:
> gcc-122233-win\bin\gcj
>         --main=Test
>         -fjni
>         -Djava.library.path=lib
>         -Dsun.java2d.fontpath=
>         -Djava.home=.
>         -Djava.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
>         -Dawt.toolkit=sun.awt.windows.WToolkit
>         -Dsun.io.unicode.encoding=UnicodeLittle
>         -Llibs/win
>         -Ilibs/win/gui/gui.jar
>         -oC:\JavaNativeCompiler-1.1.1\compiled\test.exe
>         -s
>         -O2
>         c:\temp\templib\*
>         -findirect-dispatch
>         -ljncTrial
>         -IC:\\EclipseWorkspace\Test\src
>         @C:\Temp\JNCTempaoljps.out\SourceListaoljpt.list
>
> It's worth noting that c:\temp\templib contains the .o files extracted 
> from libgcj.a using ar.exe x libgcj.a
It seems that the command is missing  '-Wl,--whole-archive' before 
'c:\temp\templib\*' and '-Wl,--no-whole-archive' after it.

,Ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-11-30 21:15     ` Ben Gardiner
@ 2009-12-04  8:34       ` Keith Boynton
  2009-12-04  9:47         ` Andrew Haley
  0 siblings, 1 reply; 10+ messages in thread
From: Keith Boynton @ 2009-12-04  8:34 UTC (permalink / raw)
  To: Ben Gardiner; +Cc: Andrew Haley, java

Hi guys,

Sorry for the delay in providing some feedback, I was trying to resolve some 
nuances in the Java Native Compiler that were making it difficult to specify 
the flags in the correct order. I was unable to resolve that, so I switched 
to straight command line entry.

I tried your suggestion, here's the full command:

1. cd to src tree containing the .java source
2. Execute the following: C:\JavaNC\gcc-122233-win\bin\gcj -o 
C:\JavaNC\projects\Test\compiled\test.exe -Wl,--whole-archive -lgcj_properties 
 -Wl,--no-whole-archive -static-libgcj --main=Test

This gives me the following error at compile time:
C:\Users\KEITHB~1\AppData\Local\Temp/ccw9aaaa.o: In function 
`main':C:/Users/KEITHB~1/AppData/Local/Temp/ccCuaaaa.i:(.text+0x25): 
undefined reference to `Test::class$$'
collect2: ld returned 1 exit status

Any help would be greatly appreciated

Keith 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-12-04  8:34       ` Keith Boynton
@ 2009-12-04  9:47         ` Andrew Haley
  2009-12-04 18:12           ` Keith Boynton
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2009-12-04  9:47 UTC (permalink / raw)
  To: Keith Boynton; +Cc: Ben Gardiner, java

Keith Boynton wrote:
> Hi guys,
> 
> Sorry for the delay in providing some feedback, I was trying to resolve some 
> nuances in the Java Native Compiler that were making it difficult to specify 
> the flags in the correct order. I was unable to resolve that, so I switched 
> to straight command line entry.
> 
> I tried your suggestion, here's the full command:
> 
> 1. cd to src tree containing the .java source
> 2. Execute the following: C:\JavaNC\gcc-122233-win\bin\gcj -o 
> C:\JavaNC\projects\Test\compiled\test.exe -Wl,--whole-archive -lgcj_properties 
>  -Wl,--no-whole-archive -static-libgcj --main=Test
> 
> This gives me the following error at compile time:
> C:\Users\KEITHB~1\AppData\Local\Temp/ccw9aaaa.o: In function 
> `main':C:/Users/KEITHB~1/AppData/Local/Temp/ccCuaaaa.i:(.text+0x25): 
> undefined reference to `Test::class$$'
> collect2: ld returned 1 exit status

You haven't given gcj anything to compile.  :-)

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: java.lang.NoClassDefFoundError: java.text.DecimalFormat
  2009-12-04  9:47         ` Andrew Haley
@ 2009-12-04 18:12           ` Keith Boynton
  0 siblings, 0 replies; 10+ messages in thread
From: Keith Boynton @ 2009-12-04 18:12 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Ben Gardiner, java

Oh my, how embarrassing, that does make sense though, appreciate it :)

I'll update the thread with my progress....

Keith 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-12-04 18:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-30 15:39 java.lang.NoClassDefFoundError: java.text.DecimalFormat Keith Boynton
2009-11-30 15:45 ` Andrew Haley
2009-11-30 21:13   ` Keith Boynton
2009-11-30 21:15     ` Ben Gardiner
2009-12-04  8:34       ` Keith Boynton
2009-12-04  9:47         ` Andrew Haley
2009-12-04 18:12           ` Keith Boynton
2009-11-30 18:29 ` Ben Gardiner
2009-11-30 18:33   ` Andrew Haley
2009-11-30 21:13     ` Keith Boynton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).