Results 1 to 2 of 2
  1. #1
    Swamynathan is offline Member
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default Trouble WIth Packages

    Hi,

    I am new to Java and am using a Eclipse compiler.I learning how to make new packages in Java(Herbert) and tried to create one . it goes like this

    Java Code:
    package MyPkg1;
    
    class Balance{
    	String name;
    	double balance;
    	
    	Balance(String n, double b){
            	name = n;
    		balance = b;}
    	
    	void show(){
    		if (balance <=0)
    			System.out.println("Balance NIL");
    		
    		System.out.println("Mr." + name + ", the balance n your acount is Rs." +balance);}
    }
    
    class PackgeDemo {
    public static void main(String args[]){
    	
    	Balance newbalance = new Balance("hari", 998.22);
    	
    		newbalance.show();
    	}
    }
    The compler is showing the following error

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at PackgeDemo.main(PackgeDemo.java:25)

    i created a CLASSPATH in the Env. variables with the following address

    C:\Users\Hari\workspace\MyPkg1

    Please Help
    Last edited by Norm; 09-14-2011 at 01:28 PM. Reason: added code tags

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,268
    Rep Power
    25

    Default Re: Trouble WIth Packages

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    at PackgeDemo.main(PackgeDemo.java:25)
    What is the statement at line 25?
    Can you compile the program with the javac program and get the compiler error? Your IDE is NOT showing what the error is.
    Here is what a normal javac error looks like:
    Java Code:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^

Similar Threads

  1. How to use my own packages?
    By Vardiane in forum New To Java
    Replies: 4
    Last Post: 04-22-2011, 04:53 AM
  2. Packages
    By urbim in forum Eclipse
    Replies: 2
    Last Post: 07-02-2009, 02:01 PM
  3. Replies: 3
    Last Post: 02-12-2008, 11:03 AM
  4. Using packages
    By prfalco in forum New To Java
    Replies: 5
    Last Post: 01-31-2008, 10:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •