ClassFormatError in J2ME execution...

I have a simple "Hello World" midlet. I can compile the midlet fine but while running it I un into the error
ALERT: java/lang/ClassFormatError: Bad version information.

Attached is the console output.

I am using WTK 2.2 and JDK 1.6 u2. I created this project as J2ME project with a single J2ME module.

Just not sure what am I missing. The same thing works in NetBenas but NB is just not as much pleasure as Selena.



Attachment(s):
IdeaError.txt
17 comments
Comment actions Permalink

Looks like I got the problem resolved but now I am running into another issue:

I cannot call any static method on another class in the same package. All the classes in the package are public and all the methods in that class are public. It cannot find the class itself. But this happens only during module build - the editor shows all fine and is even able to do auto-complete etc.

This is becoming just too painful to develop J2ME with IntelliJ. NB just seems to work right out of the box.

0
Comment actions Permalink

I think I found a work around but it's just wacky

this is the code I have that does not work

public class SomeClass
{
public static void doSome()
{
InputStream is = SomeClass.class.getResourceAsStream("someFile");
}
}

this code works

public class SomeClass
{
public static void doSome()
{
InputStream is = new SomeClass().getClass().getResourceAsStream("someFile");
}
}

For another class' static method I had to do the same - create an instance and then call an instance method that calls the static method.

Looks like something very basic wrong???

0
Comment actions Permalink

Hello Vinay,

Could you please provide "build" output as well as project example cause
it works fine for me

Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Looks like I got the problem resolved but now I am running into
another issue:

I cannot call any static method on another class in the same package.
All the classes in the package are public and all the methods in that
class are public. It cannot find the class itself. But this happens
only during module build - the editor shows all fine and is even able
to do auto-complete etc.

This is becoming just too painful to develop J2ME with IntelliJ. NB
just seems to work right out of the box.



0
Comment actions Permalink

Attaching the output :

Information:Fatal Error: Unable to find method initCause
Information:Compilation completed with 1 error and 0 warnings
Information:1 error
Information:0 warnings
C:\dvlp\ideaTest3\src\Jargoneer.java
Error:Error:line (25)cannot find symbol method initCause(java.lang.ClassNotFoundException)

Also attaching the zip file that contains the project and iml files.



Attachment(s):
IdeaTest3.zip
0
Comment actions Permalink

Hello Vinay,

I've checked (WTK 1.4) and I've got problems with getResourcesAsStream(...)
- NoClassDefFound.class not found. As far as I know Reflection api is not
supported for J2ME.

Seems that bad code is green though :(

Thank you

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Attaching the output :

Information:Fatal Error: Unable to find method initCause
Information:Compilation completed with 1 error and 0 warnings
Information:1 error
Information:0 warnings
C:\dvlp\ideaTest3\src\Jargoneer.java
Error:Error:line (25)cannot find symbol method
initCause(java.lang.ClassNotFoundException)
Also attaching the zip file that contains the project and iml files.



0
Comment actions Permalink

that explains it - though would be nice if the editor could catch it.

The other side effect of this is

I have class A calling a static method in Class B
Class B was accidentally using reflection thru B.class.getResourceAsStream();

With code like this - compilation of A.java fails which should not.

0
Comment actions Permalink

Hello Vinay,

I'll add corresponding inspection.

If you compile only class A then it compiles. No problem. But class B won't
fit kvm in any case ...

Thank you

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

that explains it - though would be nice if the editor could catch it.

The other side effect of this is

I have class A calling a static method in Class B
Class B was accidentally using reflection thru
B.class.getResourceAsStream();
With code like this - compilation of A.java fails which should not.



0
Comment actions Permalink

Few more questions
- where do my sout go? I don't see them in the run output window.
- When the exception occurs - the stack trace does not show the line numbers but something else like at com.mycom.mypack.StoreGenerator.generateStoreInfo(+34) - 34 is not the line number in the file or the method.
- I have a code like new StoreGenerator().getClass().getResourceAsStream("someFile.txt"); and I have copied someFile.txt in build\production\IdeaTest, build\test\IdeaTest and build dir , still the call above results in returning a null stream. I thought build\production\IdeaTest should have been in classpath since that is the compiler output path and all classes are getting in there.

0
Comment actions Permalink

Original question answered - but I have few more questions about the J2ME development that I have added to this thread.

0
Comment actions Permalink

souts are coming out fine - stupid user error.

0
Comment actions Permalink

Hello Vinay,

Check ?*.txt in compiler settings for your resource files. If txt files are
used as resources then compiler would copy them into output directory. Otherwise
compiler won't include such files in temp executable jar.

As far as I know numbers are from byte code offsets. I agree that it would
be convenient to convert them into source code line numbers. I didn't check
such possibility. JIRA issue please?

Thank you

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Few more questions

- where do my sout go? I don't see them in the run output window.

- When the exception occurs - the stack trace does not show the line
numbers but something else like at
com.mycom.mypack.StoreGenerator.generateStoreInfo(+34) - 34 is not the
line number in the file or the method.

- I have a code like new
StoreGenerator().getClass().getResourceAsStream("someFile.txt"); and I
have copied someFile.txt in build\production\IdeaTest,
build\test\IdeaTest and build dir , still the call above results in
returning a null stream. I thought build\production\IdeaTest should
have been in classpath since that is the compiler output path and all
classes are getting in there.



0
Comment actions Permalink

http://www.jetbrains.net/jira/browse/IDEA-14136

Not sure if I created this in the correct component. I did not find anything for J2ME.

0
Comment actions Permalink

Hello Vinay,

It's ok. Thank you

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

http://www.jetbrains.net/jira/browse/IDEA-14136

Not sure if I created this in the correct component. I did not find
anything for J2ME.



0
Comment actions Permalink

As one of the moderators of IT forum I hate when people re-open old threads for no reason, as it may be taken now in my case. However I believe that my problem is related to the problem posted in this thread.

I just picked up new book on mobile graphics. I was trying to compile one of the examples book provided when I got following error



Information:Fatal Error: Unable to find method initCause

Information:Compilation completed with 1 error and 0 warnings

Information:1 error

Information:0 warnings

C:\J2ME\IntelliJ\m3g04b\src\m3g04\Main.java

Error:Error:line (26)cannot find symbol method initCause(java.lang.ClassNotFoundException)



First I thought I made some error rewriting code, but later it was confirmed that code is correct and it will happily build and run under NetBeans 6.1 (had to download this IDE just to check if it is realy problem of IDEA).



Can somebody advice or help on the matter?

0
Comment actions Permalink

Hello Peter,

Seems that smth wrong with your mobile SDK. Which one do you use? Which language
level is used for mobile module?

Thanks

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

As one of the moderators of IT forum I hate when people re-open old
threads for no reason, as it may be taken now in my case. However I
believe that my problem is related to the problem posted in this
thread.

I just picked up new book on mobile graphics. I was trying to compile
one of the examples book provided when I got following error

Information:Fatal Error: Unable to find method initCause

Information:Compilation completed with 1 error and 0 warnings

Information:1 error

Information:0 warnings

C:\J2ME\IntelliJ\m3g04b\src\m3g04\Main.java

+Error:Error:line (26)cannot find symbol method
initCause(java.lang.ClassNotFoundException)+

First I thought I made some error rewriting code, but later it was
confirmed that code is correct and it will happily build and run under
NetBeans 6.1 (had to download this IDE just to check if it is realy
problem of IDEA).

Can somebody advice or help on the matter?



0
Comment actions Permalink

In this cased I used Sony Ericsson 2.5.0.1beta (semc_java_me_cldc_sdk.2-5-0-1beta.exe), however since then I moved to 2.5.0.2(semc_java_me_cldc_sdk.2-5-0-2.exe) and this give me completely different errors on same set of project. Has special dislike to Math library, made complains to PI, cos() and others. I do not realy understand why then NetBeans work with same WTK without any problems. I'm really confused...



@Which language level is used for mobile module?

I did not fully understand to this question. Can you please elaborate?

0
Comment actions Permalink

I have a similar error to what already was mentioned here: I tried to compile and run the TimeMIDletExample (http://jinjector.googlecode.com/files/TimeMIDletExample(2009-03-12).zip) from Google's jinjector project (http://code.google.com/p/jinjector/) with WTK2.5.2. Now, after some tweaking it compiles and runs successfully with ant; however, the very same project's compilation fails with cannot find symbol method initCause(java.lang.ClassNotFoundException) on a line where .class is used. There was a mention of lack of reflection under J2ME; my question is: how come it compiles with ant but not with IDEA? Is there anything I can do the get rid of this error?

0

Please sign in to leave a comment.