• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

packages

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//file: LML.java
package packLML;
public class LML {}

//file: Test5.java
//Unamed package in the current directory.(C:\SCJP\Threads\)
import packLML.*;
public class Test5 {

public static void main(String[] args) {

LML lml = new LML(); //line (1)
}
}

LML.java compiled with out any Error as expected.
Where as when I tried to compile Test5.java this is the error I got...

Test5.java:7: cannot access LML
bad class file: .\LML.java
file does not contain class LML
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
LML lml = new LML();
^
If I change line (1) to

packLML.LML lml = new packLML.LML();

It compiles fine.Even after importing packLML why am I not able to access packLML.LML by its shortcut name LML???
 
Girish Nagaraj
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Question is when line

import packLML.*;

is compiling fine(importing fine) why am I not able to access packLML.LML by its short cut LML?
 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in class path give upto that directory, then it will run,with that . operator.
 
Girish Nagaraj
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi bnkiran kumar,

Could you please explain that in detail.
 
bnkiran kumar
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
give path upto packLML in classpath, it will work
reply
    Bookmark Topic Watch Topic
  • New Topic