Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 10
Registered: ‎03-04-2010
My Device: Blackberry Curve 8300
My Carrier: Telus
Accepted Solution

Problems storing information

Hello,

 

I've started developping JAVA for Blackberry a few days ago. I'm new to both of those technologies.

 

I've started by the beginning, by doin' every tutorials for the beginners on the RIM Website.

 

Now I have mounted the app to store data into Vector. But it seems that when I save the info with the "save" button it doesn't appears in the debug console. I'd like to know if I should see that kind of info in the console when Idebug an app.

 

Here is the pdf for the app. I'm talkin' about :
http://na.blackberry.com/developers/resources/A13_Storing_Persistent_Data_V2.pdf

 

Thanks in advance for anyone who will help me out there.

 

Lucas

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problems storing information

in the sample there is no console output, the info is put on the screen fields.

 

you can use System.out.println() to send output to the debug console.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 10
Registered: ‎03-04-2010
My Device: Blackberry Curve 8300
My Carrier: Telus

Re: Problems storing information

Thanks for the quick answer. Didn't though it would be so fast.

 

Can you print the content of a Vector with this function ?

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Problems storing information

In short, yes.

 

 

Vector v = new Vector (3, 1);

v.addElement (new String ("Hello"));
v.addElement (new String ("World"));
v.addElement (new String ("!!!!!"));

//Console Output
System.out.println (v.elementAt (0)); //prints "Hello"
System.out.println (v.elementAt (1)); //prints "World"
System.out.println (v.elementAt (2)); //prints "!!!!!"
System.out.println (v);  //calls the Vector.toString method. I believe
                         //the output is something like:
                         //{"Hello", "World", "!!!!!"}
System.out.println (v.toString); //Same as above
System.out.println (v.equals (v)); //Since v == v, this will print "true"
System.out.println (v.isEmpty ()); //Since v is not empty, this will
                                   //print "false" (or maybe "False")
System.out.println (v.indexOf ("Hello")); //prints "0", because v [0] ==
                                          //"Hello"
System.out.println (v.size ()); //prints "3", because v has 3 elements

 

 

System.err.println (); is similar, but I'm not sure where the output goes -- I've never actually applied it to a project.

 

Hope that helps,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Contributor
Posts: 10
Registered: ‎03-04-2010
My Device: Blackberry Curve 8300
My Carrier: Telus

Re: Problems storing information

In fact it really looks what I wanted. But the only problem I have is that I can't view trough my console these print I do with  System.out.println(). I'm currently searching over the Web for people who had the same problem. They all say to user the BLackberry Simulator to debug and it should works...but it doesn't for myself...

 

Don't know if you can help me with that I know that it's another problem and I should open another subject in the forum but I'm taking the guess by asking you the question.

 

Thanks your help is really appreciated.

 

Lucas

Developer
Posts: 77
Registered: ‎01-27-2010
My Device: Bold 9000
My Carrier: AT&T

Re: Problems storing information

 


lucas_cote wrote:

In fact it really looks what I wanted. But the only problem I have is that I can't view trough my console these print I do with  System.out.println(). I'm currently searching over the Web for people who had the same problem. They all say to user the BLackberry Simulator to debug and it should works...but it doesn't for myself...


Quick question.  When you run the program in debug mode is anything being printed to the console?  For me it prints a bunch of information that I don't really care about and the statements I printed are hidden in that output.

 

 

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Problems storing information

[ Edited ]

You need to launch a simulator through your JDE. This could be Elcipse, Netbeans, or even the BlackBerry Specific JDE.  When you are ready to launch the simulator, make sure you're launching in "Debug" mode. For the BlackBerry JDE this is really the only option, but for Eclipse you need to manually select debug -> debug server. The output will be at the bottom of the screen by default. You must also be in debug mode for your application to stop at Breakpoints.

 

Screenshot - Console output:

 

 

Any System.out.println () statements will be visible along with the standard console output. They may be a bit difficult to notice, however, as the simulators provide a large amount of information. Be sure to utilize breakpoint functionality to maximize your debugging effectiveness.

 

Hope that helps,

~Dom

 

EDIT: I should point out that there's no way to turn off the default debug statements. They can be difficult to read through, but we're stuck with them, as they are quite beneficial to higher-level application development.

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Contributor
Posts: 10
Registered: ‎03-04-2010
My Device: Blackberry Curve 8300
My Carrier: Telus

Re: Problems storing information

Yes when i run the program it prints a lot of information on any class, package or action done. But I don't see anything marked as «System.out.print...».

 

And when I try to include that line«System.out.println("Hello_WOrld");»  into my code it show errors in the «problems» window.

 

Problems showed :

«Description    Resource    Path    Location    Type
Syntax error on token ""Hello_WOrld"", delete this token    MusicStores.java    music_stores/src/com/rim/samples/music_stores    line 18    Java Problem»


«Description    Resource    Path    Location    Type
Syntax error on token(s), misplaced construct(s)    MusicStores.java    music_stores/src/com/rim/samples/music_stores    line 18    Java Problem»

 

 

Sorry for asking you such beginner questions but I really don't understand.

 

Here is a prinscreen to show you what I've got in the console window.

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Problems storing information

Have you imported Java.io.*? I see you remembered the semi-colon, so I don't know where that second error came from.

 

I should also point out that there's no indication of the source command on output.

 

Code:

System.out.println ("Hello World");

 

Output:

Hello World

 

Just a thought, but when you include the println statement, do you remove the */ at the end of the line? That would cause syntax errors...

 

Hope that helps,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 77
Registered: ‎01-27-2010
My Device: Bold 9000
My Carrier: AT&T

Re: Problems storing information

[ Edited ]

 


lucas_cote wrote:

Yes when i run the program it prints a lot of information on any class, package or action done. But I don't see anything marked as «System.out.print...».

 


Nothing is going to be labeled as System.out.print.  It's just going to print the output that you call so if your application has:
System.out.println("Hello, World");

 

The output will just be:
Hello, World
Try printing something and then use Ctrl-F to find what you printed.
As for your other problem that is because you are calling System.out.println() from outside a method.  Try a method like this:
public static void main(String[] args)
{
   System.out.println("Hello, World");
}

 

The main method is called when you start the program.  From there it can create objects and call other methods.  The only thing you can do outside of a method is declare variables and assign values to variables.