• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error in accessing string in j2me

 
gargi chauhan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

geting error when using string in j2me wireless toolkit.

String s=tb.getString(); //where tb is my textbox
String S1="hello"+s;

in above code

C:\WTK20\apps\myprogram\src\myprogram.java:44: cannot access java.lang.StringBuilder
class file for java.lang.StringBuilder not found
String S1="hello"+s;
^
1 error
com.sun.kvem.ktools.ExecutionException
Build failed
 
Ifteqar Ahmed
Ranch Hand
Posts: 85
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you import String Class Library?
 
gargi chauhan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ifteqar Ahmed wrote:Did you import String Class Library?


i impoty java.lang.* libray
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ifteqar Ahmed wrote:Did you import String Class Library?

Badly worded, and completely irrelevant. All classes in the java.lang package are imported automatically. (gargi, that means you never need to
impoty java.lang.* libray

http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.5

How did you compile your code? Java ME complies to Java 1.3 and StringBuilder was introduced in Java 1.5. A Java 1.5+ compile will substitute String concatenation code with StringBuilder.append(...). You need to compile to a target of version 1.3. The exact way in which you do that will depend on your development environment.
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/javac.html#crosscomp-options
 
gargi chauhan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:
Ifteqar Ahmed wrote:Did you import String Class Library?

Badly worded, and completely irrelevant. All classes in the java.lang package are imported automatically. (gargi, that means you never need to
impoty java.lang.* libray

http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.5

How did you compile your code? Java ME complies to Java 1.3 and StringBuilder was introduced in Java 1.5. A Java 1.5+ compile will substitute String concatenation code with StringBuilder.append(...). You need to compile to a target of version 1.3. The exact way in which you do that will depend on your development environment.
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/javac.html#crosscomp-options


means i want to use + for concating the string but it does not work

i can concate string using only concat function but i want to use + for it
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please TellTheDetails. We can't advise you without knowing how you compile your code.

Did you go through the links I posted, particularly the second one? What don't you understand about compiling to a particular target version?
 
gargi chauhan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Please TellTheDetails. We can't advise you without knowing how you compile your code.

Did you go through the links I posted, particularly the second one? What don't you understand about compiling to a particular target version?



i m using J2ME wireless toolkit 2.0

in that Ktoolbar used to generate project and then build and run that project

but i want to used in that + for concatenation instead of function concat
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you update/upgrade your development environment. WTK 2.0 is ancient history, 2.5.1 was out at least two years ago and was superseded by the Java ME SDK 3.0, presently in version 3.0.5.

I haven't used the WTK for so long (and don't presently have it installed) that I can't remember whether there's an option to set the compile target version. If you can't upgrade to a more recent IDE, just search around in the options.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic