Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Import

 
Abhijeet Gholkar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File A.java
package my;
public class A
{
public String sayHi()
{
return "HI";
}
}
File B.java
import my.*;
class B
{
public static void main(String[] args)
{
A a = new A();
System.out.println(a.sayHi());
}
}
I compiled A.java using following command
javac -d . A.java
even then class A is not available in class B?
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use
javac -d . -classpath . A.java
Jamal Hasanov
www.j-think.com
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and run class B with the same classpath parameter.
Jamal Hasanov
www.j-think.com
 
Abhijeet Gholkar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to mention that the code works when in B.java i say
import my.A;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic