• 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

compiling java package class referring a default package class.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I am trying to compile a java class having a package defination referring a java class with a default package.

The code for the default package class is .

public class Test{.


public static void main(String[] args){
System.out.println("Hello World!");

}
}

This class compiles fine.

I have another class called PackJava, whose code is :

package test;
import Test;
public class PackJava{
public static void main(String[] args){
Test test = new Test();
System.out.println("Hello World!");
}
}


I have Test file in the windows path
D:\development\packagetest\example
and the PackJava java file in the path
D:\development\packagetest\example\test
I have set the CLASSPATH environment varibale as
D:\development\packagetest\example;.


When I try to compile the PackJava from the
D:\development\packagetest\example path giving the command as
javac -classpath . test\PackJava.java
or
javac -classpath %CLASSPATH% test\PackJava.java
it gives me error,
Do any of you have an idea of the parameter i should pass
to the -classpath option
Thanks
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no reason to import things from the deault package. In fact, the java compiler won't let you (you will receive an "expected ." error). Remove the line "import Test; " and try compiling again.
 
Your buns are mine! But you can have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic