Convert double to string and vice versa? - CLDC and MIDP

Can anyone help me with this? Been googling but what I found doesn't seem to work... Am I missing some libraries or something?
The Error I get:
Compiling 1 source file to /home/arturas/NetBeansProjects/FuelCalc/build/compiled
/home/arturas/NetBeansProjects/FuelCalc/src/hello/ cannot find symbol
symbol  : variable Double
location: class hello.HelloMIDlet
                String text = Double.toString(value);
1 error
/home/arturas/NetBeansProjects/FuelCalc/nbproject/build-impl.xml:377: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)It's in this part of the code obviously (it marks the word Double):
double value = 0.11;
String text = Double.toString(value);and my libraries used:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.lang.*;
import java.*;I've put the last three lines in imports out of desperation, but it didnt' help... :/
Can anyone help me? Thanks. :)
Edited by: arcelivez on Aug 26, 2010 12:00 PM
Oh, just a remark - I'm not much into java and haven't been using it for like almost a year. Oh and in the project settings I chose CLDC 1.0 and MIDP 1.0, because I had some problems with the newer CLDC and MIDP on my current phone that I'm testing on... 

Figured out that this problem is in CLDC 1.0 only. CLDC 1.1 works fine and it works fine on my phone too thank God. :D 

Yup, CLDC 1.0 doesn't support floating point mathematics.


import java.util.Arrays PROBLEM

I am trying to use the Arrays.toString method
String temp = Arrays.toString(testLayerMap);I have added the import line
import java.util.Arrays.*;However I get an error stating package does not exist.
I am coding in Netbeans 6.1 IDE using JDK 1.6.0_06
Any clues? 
import java.util.Arrays;to import the Arrays class.
import java.util.Arrays.*;would import all classes in the Arrays package. But Arrays is not a package; it's a class. 
Ahh yes my bad, that was from me messing around to solve the problem.
When I do
import java.util.Arrays;I get : cannot find symbol : class Arrays
any ideas? 
The Arrays class has been around since Java 1.2, I assume you are using a later version than that.
Make sure you have saved your class and that you are attempting to compile the correct version of your class. If all else fails, post your code here as well as the EXACT error message. Copy and paste it, do not paraphrase. 
Denvar wrote:
Ahh yes my bad, that was from me messing around to solve the problem.
When I do
import java.util.Arrays;I get : cannot find symbol : class Arrays
any ideas?Either you have a ridiculously old version of Java, or you've putched up your install.
Well my project is a little too large to past here, 5 classes and around 1200 lines of code.
To make sure the project as a whole compiles and runs flawlessly without trying to use Arrays.toString or without the Arrays import.
I am using a variety of imports which are all also running fine (I am developing a multiplayer J2ME game)
The only changes to my code between working fine and failing to compile are those two lines I quoted, remove/comment out those two lines and everything runs fine again.
I have redownloaded/installed Netbeans 1.6 and JDK 1.6.0_06 still no luck.
Tried a new blank Hello World project and attempted to do the import but I still get the error, would seem like a botched install, but twice in a row? with other imports working?
Just for kicks here is a new blank class I tried doing this on :
* To change this template, choose Tools | Templates
* and open the template in the editor.
import java.util.Arrays;
* #author Server2003
public class NewClass {
}When I try to compile I get this
Compiling 1 source file to C:\Documents and Settings\Server2003\My Documents\NetBeansProjects\MobileApplication1\build\compiled
C:\Documents and Settings\Server2003\My Documents\NetBeansProjects\MobileApplication1\src\ cannot find symbol
symbol  : class Arrays
location: package java.util
import java.util.Arrays;
1 error
C:\Documents and Settings\Server2003\My Documents\NetBeansProjects\MobileApplication1\nbproject\build-impl.xml:354: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)And in the IDE the line is highlighted red and says
cannot find symbol
symbol  : class Arrays
location: package java.util 
Try compiling from the command line. If this works then it is Netbeans that is borked. Another cause maybe if you have created your own Arrays class or even your own java.util package. 
Good catch, compiling from commandline worked fine on the Hello World java file. I guess that means Netbeans is screwey.
I have downloaded and reinstalled Netbeans 6.1 Mobility for a third time and still no good.
I am using the following import around various classes with no problems :
import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import*;So far only java.util.Arrays is giving me a problem.
I havent created my own Arrays class or util package 
Denvar wrote:
Good catch, compiling from commandline worked fine on the Hello World java file. I guess that means Netbeans is screwey.
I have downloaded and reinstalled Netbeans 6.1 Mobility for a third time and still no good.Mobility?
I am using the following import around various classes with no problems :
import java.util.*;
import*;Ah ha.
This would have been worth mentioning a while ago. java.util.Arrays does not exist in J2ME. You can look up the API reference for the particular thing you are using here []
Basically all that is in the java.util package is stuff from long, long ago. Collections and utility classes like Arrays are available to you. 
In future, Java ME related questions should be asked in the [CLDC and MIDP forum|].
When typing the import statement in NetBeans, Code Completion would have shown you that there is no java.util.Arrays class.
When I type the input statement coe completion show me this after java.util.
You could also have referred to the package documentation, which would have shown you the classes in the MIDP java.util:{color:black}Interfaces 
Denvar wrote:
When I type the input statement coe completion show me this after java.util.Yes that's all that is available in J2ME. Did you not see the link I posted earlier?
Not to bug but since your question has been answered how about assigning those dukes? 
since your question has been answered how about assigning those dukes?"But cotton, you haven't told me how to use the Arrays.toString method :("
Teh codez!
/* base copied from old java.util.Arrays. StringBuffer instead of StringBuilder must be used because StringBuilder does not exist in J2ME*/
public static String toString(Object[] a) {
        if (a == null)
            return "null";
        if (a.length == 0)
            return "[]";
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < a.length; i++) {
            if (i == 0)
                buf.append(", ");
            buf.append(String.valueOf(a));// wtf? Why not call toString() on the object?
return buf.toString();

import javax.servlet.*;  ...

I am a new user, teaching myself java. I am writting a servlet that is supossed to get data from a database that I created. I am pretty sure about my code, and the connectivity - as a matter of fact I was able to connect to the database in a nonservlet type java program. However, I am getting these errors in the JBuilder environment that I use (supose u'd need to be familiar with it, but perhaps not)
"": Error #: 704 : cannot access directory javax\servlet at line 16, column 1
"": Error #: 704 : cannot access directory javax\servlet\http at line 17, column 1
As u can see, it does not like my....
import javax.servlet.*;
import javax.servlet.http.*;
What is going on here? Some one please help, I've been battleing for over a day on this. Thank you guys. 
i think your class path is not pointing to the root of the javax package. 
ah, jbuilder....
if you go into project properties you can add packages to the project there. try that....


i�m using the Wireless Toolkit 2.0 Beta2 and want to create an tone sequence but when I try to create a ToneControl I always get """: Error #: 300 : class ToneControl not found in class euroman.Music at line 27, column 7", My imports are: "import*;
Does anyone know why and has a solution for it because when I look at the help-files it states that I have to use a ToneControl:
Hope this helps

Don t understand....

Hi there....
My problem is that when i write this code :
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class MyMidlet extends MIDlet implements CommandListener, ItemCommandListener{
The IDE says that he "can t find the symbol : ItemCommandListener.....
Is a package missing or something like that? 
No, its because that interface doesn't exist. I assume you mean ItemStateListener. ;) 
.. No i m sure it exists, you can type "ItemCommandListener" in search forum and you ll see it...
My real problem is that the following code doesn t match :
StringItem strItem = new StringItem("Default: ", "Set",Item.BUTTON);
The error is : Cannot resolve variable BUTTON
location javax.microedition.lcdui.Item;
I thought that it was because the implements of ItemCommandListener was missing cause i saw it in some part of code in this forum.... 
It looks like you're trying to compile MIDP 2.0 code against MIDP 1.0 libraries.
And how can i convert it into a midp 2.0 project????
I use the NEtBeans 3.6 IDE cant it create only midp 1.0 projects???? 
Oki I ve found
Thx ;-) 
hi salvino me am also facing same problem about midp packages..cannot resolve symbol, doesnot exist packages..
how 2 proceed..pls..hepl me
thankful 2u
I ve got to choose another default compiler, select MIDP2.0 instead of MIDP1.0 and it will work ( i can t tell you how it depends of the IDE you use.... i think the icon which can open the menu for it is usually nearby the field where you can choose the default emulator..)
That s what i ve done

Unknown ALERT while loading class

When I try to load a class in the kvm I get the following error:
"ALERT: Cannot create class in system package"
I've done a Google search, and a search on this site, with no luck. Am I the first person to get this error?
I have a few ideas about what might be causing it. If anyone could confirm or deny them, I'd appreciate it:
#1. This is prime culprit-> Dynamic class loading via Class.forName. Does the stripped down JVM support all the functionality I need for this?
#2. Am I not specifying the classpath correctly? I tried adding J2ME's src directory and J2SE's rt.jar to the classpath to no avail.
#3. Did I preverify incorrectly? I didn't get any errors, but without verbose output, I can't be sure exactly what happened anyway.
Any help would be greatly appreciated.
--Dan Clark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Did you find the solution? I've the same problem... 
I'm not 100% sure, but I think that we fixed this problem was caused when we tried to use additional java classes. If you do this, as we found out, you need to add the new paths to your bootclasspath instead of your regular classpath 
You can't use system packages like java.* in your own classes.
Valid CLDC application are not allowed to load
other java.* system classes than those that are
officially supported by CLDC.
The behaviour of the kvm whether allow loading
of system (e.g. java.*) classes is controlled
defined in header file kvm/VmCommon/h/main.h
in kvm source distribution.
So what is the solution for this problem??? 
What do you mean by "bootclasspath instead of your regular classpath " ?? 
The question is whether you have created some of your classes within the java.* or javax.* space. That has to be avoided as most micro VMs refuse to load such classes. silvano. 
Let me explain the situation in more detail
I have a MIDlet class, that is in my own package JMarket:
package JMarket;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public void startApp() {
mm = new Form("Welcome to JVS!");
//make connection to Bluetooth Server
connect = new JvsConnect(); if I uncomment this line error message disappears
Let me now show you my JvsConnect class:
package JMarket;
import javax.bluetooth.*;
import com.rococosoft.impronto.configuration.*;
import com.rococosoft.impronto.util.*;
public class JvsConnect {
These two lines cause the problem.When I uncomment them error is gone
private static LocalDevice device = null;
private final static UUID uuid = new UUID(0x7C3434CC);
public JvsConnect() {
System.out.println("Starting Bluetooth Connection...");
In my project properties(in JBuilder), as required library I have Impronto's APIs (without them I cannot say " import com.rococosoft.impronto.util.*; " - which is needed for bluetooth connection "LocalDevice" and others..)
So as you can see when I only uncomment two lines from JvsConnect class error message is gone and MIDlet can do everything ok....Otherwise it always says ALERT: Cannot create class in system package
What is wrong???
I guess I solved the problem!!!
I downloaded MMAPI from "" and added it to my project from "Required Libraries"... and compiled my project with MIDP1.0
It works now!!! From MIDP2.0 I olny used VIDEO/AUDIO features...and now I got them directly from MMAPI 1.0
Hope won't have any problems as I develop my code.
Will let you know when I finish the project
Thanks for help!
Muhammed Mamedov
Fatih University