Results 1 to 4 of 4
  1. #1
    balajir is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default static import only from classes and interfaces

    I am a java newbie

    I am trying to execute a simple java program


    FileA.java

    package mynack;
    public class FileA
    {
    public static int i=100;
    }

    FileABC.java
    import static mynack.FileA;

    public class FileABC
    {
    public static void main (String [] arg) {
    FileA S = new FileA ();
    System.out.println(S.i);
    }

    }

    Below is the Error
    File: C:\DR JAVA\mynack\FileABC.java [line: 1]
    Error: C:\DR JAVA\mynack\FileABC.java:1: static import only from classes and interfaces
    File: C:\DR JAVA\mynack\FileABC.java [line: 1]
    Error: C:\DR JAVA\mynack\FileABC.java:1: cannot find symbol
    symbol: class mynack
    File: C:\DR JAVA\mynack\FileABC.java [line: 6]
    Error: C:\DR JAVA\mynack\FileABC.java:6: cannot access FileA
    bad class file:
    C:\DR JAVA\mynack\FileA.class
    class file contains wrong class: mynack.FileA
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    File: C:\DR JAVA\mypack\TestABC.java [line: 1]
    Error: C:\DR JAVA\mypack\TestABC.java:1: static import only from classes and interfaces
    File: C:\DR JAVA\mypack\TestABC.java [line: 1]
    Error: C:\DR JAVA\mypack\TestABC.java:1: cannot find symbol
    symbol: class mypack

    Please help me here

  2. #2
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Java Code:
    import static mynack.FileA;
    What's that for? Change it to this:
    Java Code:
    package mynack;
    -Gary-

  3. #3
    balajir is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    I am getting error identifier expected

  4. #4
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    5

Similar Threads

  1. Replies: 8
    Last Post: 04-16-2012, 11:00 PM
  2. Static methods or individual classes?
    By nik_meback in forum AWT / Swing
    Replies: 6
    Last Post: 12-01-2010, 03:52 PM
  3. Call Static Methods Outside Classes
    By Insomniac Riot in forum New To Java
    Replies: 4
    Last Post: 05-11-2010, 10:03 PM
  4. static vs. non-static nested classes
    By rinke in forum Advanced Java
    Replies: 8
    Last Post: 06-30-2009, 07:15 AM
  5. Replies: 1
    Last Post: 08-01-2007, 09:25 PM

Posting Permissions

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