S
Salil P
Hi,
Sorry for a slightly long post...
I have a (probably trivial?) problem with compilation of java sources
that I can reproduce with the simple example here.
There are two classes that I need to compile.
Files: With source dir as E:\base\src
E:\base\src\one.java
E:\base\src\twopkg\two.java
Javac output dir: E:\base\cls
Source code:
one.java
----------------------
public class one
{
int doThis() { return 10; }
}
----------------------
E:\base\src\twopkg\two.java
----------------------
package twopkg;
public class two
{
int doThat() { return 20; }
one returnOne() { return new one(); }
}
----------------------
Compilation gives errors:
E:\base>javac -sourcepath src -d cls src\one.java src\twopkg\two.java
src\twopkg\two.java:7: cannot resolve symbol
symbol : class one
location: class twopkg.two
one returnOne() { return new one(); }
^
src\twopkg\two.java:7: cannot resolve symbol
symbol : class one
location: class twopkg.two
one returnOne() { return new one(); }
^
2 errors
----------------------
Since "one" class is not in a package, "import one;" in two.java gives
a compilation saying something like "Expecting a . instead of ;"
It seems that I am not able to refer a class with no package from a
class within a package. Is this right? / Am I doing something wrong?
Also, I understand it is bad form to have classes without packages, but
I am writing a code generation tool and need to support this possible
scenario...
Thanks in advance,
Salil P
Sorry for a slightly long post...
I have a (probably trivial?) problem with compilation of java sources
that I can reproduce with the simple example here.
There are two classes that I need to compile.
Files: With source dir as E:\base\src
E:\base\src\one.java
E:\base\src\twopkg\two.java
Javac output dir: E:\base\cls
Source code:
one.java
----------------------
public class one
{
int doThis() { return 10; }
}
----------------------
E:\base\src\twopkg\two.java
----------------------
package twopkg;
public class two
{
int doThat() { return 20; }
one returnOne() { return new one(); }
}
----------------------
Compilation gives errors:
E:\base>javac -sourcepath src -d cls src\one.java src\twopkg\two.java
src\twopkg\two.java:7: cannot resolve symbol
symbol : class one
location: class twopkg.two
one returnOne() { return new one(); }
^
src\twopkg\two.java:7: cannot resolve symbol
symbol : class one
location: class twopkg.two
one returnOne() { return new one(); }
^
2 errors
----------------------
Since "one" class is not in a package, "import one;" in two.java gives
a compilation saying something like "Expecting a . instead of ;"
It seems that I am not able to refer a class with no package from a
class within a package. Is this right? / Am I doing something wrong?
Also, I understand it is bad form to have classes without packages, but
I am writing a code generation tool and need to support this possible
scenario...
Thanks in advance,
Salil P