BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-31-2009, 03:58 PM   #1
polys
Knows Where the Search Button Is
 
Join Date: Dec 2008
Model: 8800
PIN: N/A
Carrier: O2
Posts: 15
Question cannot find symbol error

Please Login to Remove!

Hello. I am new to java developing. I am using BB JDE to create an application. I started from a sample HelloWorld application i found online that consists of two files.

MobileApplication.java
Code:
package code;

import code.MyScreen;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.system.Characters; 


/**
 * Main application class.
 */
public class MobileApplication extends UiApplication {

    /**
     * Application entry point.
     * @param args application arguments.
     */
    public static void main(String[] args) {
        // creating application instance
        MobileApplication app = new MobileApplication();
        
        // entering event dispatcher
        app.enterEventDispatcher();
    } 

    /**
     * "MobileApplication" class default constructor.
     */
    public MobileApplication() {
        // creating screen instance
        MyScreen screen = new MyScreen();

        // displaying screen
        pushScreen(screen);
        
        
    }
    
    /**
     * Invoked when a key pressed.
     * @param key key pressed.
     * @param status status of key pressed.
     * @param time time in ms since last reset.
     * @return true if event consumed.
     */
    public boolean keyChar(char key, int status, int time) {
        boolean eventConsumed = false;

        //intercept the ESC key - exit the app if escape pressed
        if (key==Characters.ESCAPE) {
            System.exit(0);
            eventConsumed = true;            
        }
        return eventConsumed;
    }    
     
}
and MyScreen.java
Code:
package code;

import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.MainScreen;

/**
 * Screen class.
 */
public class MyScreen extends MainScreen {
    /**
     * "Close" menu item.
     */
    private MenuItem menuItemClose = new MenuItem("Close", 20, 400) {
        public void run() {
            // exiting from the application.
            System.exit(0);
        }
    };     

    /**
     * "Run" menu item.
     */
    private MenuItem menuItemRun = new MenuItem("Run", 20, 400) {
        public void run() {
            // displaying dialog box
            Dialog.alert("Hello :)");
        }
    };     


    /**
     * Default constructor.
     */
    public MyScreen() {
        super(); // calling parent's constructor

        addScreenItems(); // adding visual elements to the screen
    }

    /**
     * Adds visual elements to the screen.
     */
    public void addScreenItems() {
        setTitle("HelloWorld from Tbilisoft :)");
        this.add(new LabelField("Open menu and select \"Run\""));
        this.add(new SeparatorField());
        this.add(new LabelField("To close application - Open menu and select \"Close\" or click \"Escape\" key."));
    }

    /**
     * Processes trackwheel click.
     * @param status State of the modifier keys.
     * @param time Number of milliseconds since the device was turned on.
     * @return true if event consumed, otherwise returns false.
     */
    public final boolean trackwheelClick(int status, int time) {
        // displaying menu.
        Menu menu = new Menu();       
        makeMenu(menu, 0);
        menu.show();

        // event consumed
        return true;
    }    
    
    /**
     * Called to populate the menu.
     * 
     * @param menu Menu to which items should be added.
     * @param instance The instance of the desired menu. If your screen supports
     * only one menu, this may be ignored. By default, it is 0.
     */
    protected void makeMenu(Menu menu, int instance) {
        menu.add(menuItemRun);
        menu.add(menuItemClose);
    }           
}
I added a new file to the project called FileRead
Code:
package code;
import java.io.*;

public class FileRead {
                
    public FileRead() {    
    
    }
        
    public void read () {
        try{
            // Open the file that is the first 
            // command line parameter
            FileInputStream fstream = new FileInputStream("IMG_0001.doc");
            // Get the object of DataInputStream
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;
            
            //Read File Line By Line
            while ((strLine = br.readLine()) != null) {
                // Print the content on the console
                System.out.println (strLine);
            }
            //Close the input stream
            in.close();
        } catch (Exception e){//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }
    }
}
and when i build the project i get the following errors
Code:
C:\Java Programming\Application\code\FileRead.java:14: cannot find symbol
symbol  : class FileInputStream
location: class code.FileRead
            FileInputStream fstream = new FileInputStream("IMG_0001.doc");
            ^
C:\Java Programming\Application\code\FileRead.java:14: cannot find symbol
symbol  : class FileInputStream
location: class code.FileRead
            FileInputStream fstream = new FileInputStream("IMG_0001.doc");
                                          ^
C:\Java Programming\Application\code\FileRead.java:17: cannot find symbol
symbol  : class BufferedReader
location: class code.FileRead
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            ^
C:\Java Programming\Application\code\FileRead.java:17: cannot find symbol
symbol  : class BufferedReader
location: class code.FileRead
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
                                    ^
4 errors
I 've searched everywhere and i don't understand where the problem is. The projects builds fine without the FileRead file.
Offline  
Old 05-31-2009, 10:38 PM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

Add this to your imports:

import net.rim.device.api.io.FileInputStream;
Offline  
Old 06-01-2009, 07:45 AM   #3
polys
Knows Where the Search Button Is
 
Join Date: Dec 2008
Model: 8800
PIN: N/A
Carrier: O2
Posts: 15
Default

Quote:
Originally Posted by Dougsg38p View Post
Add this to your imports:

import net.rim.device.api.io.FileInputStream;
So i cannot use the Java libraries directly?

i.e. import java.io.*;

When i add

import net.rim.device.api.io.FileInputStream;

i still get the following errors:

Code:
C:\Java Programming\Application\code\MobileApplication.java:61: cannot find symbol
symbol  : constructor FileInputStream(java.lang.String)
location: class net.rim.device.api.io.FileInputStream
            FileInputStream fstream = new FileInputStream("IMG_0001.doc");
                                      ^
C:\Java Programming\Application\code\MobileApplication.java:64: cannot find symbol
symbol  : class BufferedReader
location: class code.MobileApplication
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            ^
C:\Java Programming\Application\code\MobileApplication.java:64: cannot find symbol
symbol  : class BufferedReader
location: class code.MobileApplication
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
                                    ^
3 errors
Offline  
Old 06-01-2009, 09:54 AM   #4
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

I note that the api defines only one constructor, FileInputStream(int fs, String fileName) which is not how you're instantiating it. api link

for all bb development, you'll have to conform your code specifically to the RIM API specification
Offline  
Old 06-01-2009, 11:36 AM   #5
polys
Knows Where the Search Button Is
 
Join Date: Dec 2008
Model: 8800
PIN: N/A
Carrier: O2
Posts: 15
Default

Quote:
Originally Posted by bemshaswing View Post
for all bb development, you'll have to conform your code specifically to the RIM API specification
so i cannot use java classes as i would normally do if i was creating a normal java application?

For example, i cannot read a file like this

PHP Code:
FileInputStream fstream = new FileInputStream("IMG_0001.doc");
            
// Get the object of DataInputStream
            
DataInputStream in = new DataInputStream(fstream);
            
BufferedReader br = new BufferedReader(new InputStreamReader(in));
            
String strLine;
            
            
//Read File Line By Line
            
while ((strLine br.readLine()) != null) {
                
// Print the content on the console
                
System.out.println (strLine);
            } 
because BufferedReader is not included in the BB apis?

Last edited by polys; 06-01-2009 at 11:38 AM..
Offline  
Old 06-01-2009, 01:02 PM   #6
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

The BlackBerry API's are built on Java ME, not Java SE. You definitely need to refer to the BlackBerry API docs as you develop the program.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Vintage V-Mac Industries Inc. Pipe Threader Vosper Drophead Threader - READ picture

Vintage V-Mac Industries Inc. Pipe Threader Vosper Drophead Threader - READ

$199.00



Vintage Mac Warehouse  3.5” Floppy Disk Solar Powered Calculator Company Swag picture

Vintage Mac Warehouse 3.5” Floppy Disk Solar Powered Calculator Company Swag

$74.00



Vintage Mac Tools AW343 Series 1/2 Pneumatic Impact Driver  picture

Vintage Mac Tools AW343 Series 1/2 Pneumatic Impact Driver

$50.00



Vintage MAC Tools UVEX Adjustable Safety Glasses Motorcycle Mechanic Lawnmower picture

Vintage MAC Tools UVEX Adjustable Safety Glasses Motorcycle Mechanic Lawnmower

$55.24



Vintage VTG A. W. Mack 122387 Large Industrial Fuse Puller 100 Amp - 600 Amp picture

Vintage VTG A. W. Mack 122387 Large Industrial Fuse Puller 100 Amp - 600 Amp

$104.99



Vintage UNHOLTZ-DICKIE MAC-6C Equipment - Untested As-is picture

Vintage UNHOLTZ-DICKIE MAC-6C Equipment - Untested As-is

$71.99







Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.