| Author |
Compiler can't find package
|
Tim Nachreiner
Greenhorn
Joined: Apr 28, 2011
Posts: 8
|
|
I can successfully compile Class1.java with this command:
C:\Dev\MyProjects\beerV1>javac src\com\example\model\Class1.java
Here is the code for Class1.java
When I try to compile Class2.java, which uses Class1, the compiler says it can't find package com.example.model
Here is the code for Class2.java
Here is the command I use for compiling:
C:\Dev\MyProjects\beerV1>javac src\com\example\web\Class2.java
What am I doing wrong?
|
 |
Ralph Cook
Ranch Hand
Joined: May 29, 2005
Posts: 479
|
|
I cannot tell what is wrong based on the information you've given us.
Please show us the folders containing each of these files, and quote the error message directly instead of telling us what it says. Copy-and-paste is good.
rc
|
 |
Tim Nachreiner
Greenhorn
Joined: Apr 28, 2011
Posts: 8
|
|
Problem solved.
I needed to include "-classpath ." in order for the compiler to go up one directory.
Thanks for your quick response.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
Did you compile Class1 first?
|
 |
Tim Nachreiner
Greenhorn
Joined: Apr 28, 2011
Posts: 8
|
|
Campbell Ritchie wrote:Did you compile Class1 first?
Yes.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
I think we shall have to do what Ralph Cook said earlier, and ask to see your folder structure.
|
 |
Tim Nachreiner
Greenhorn
Joined: Apr 28, 2011
Posts: 8
|
|
Campbell Ritchie wrote:I think we shall have to do what Ralph Cook said earlier, and ask to see your folder structure.
Thanks anyways, but if you read my second post, I've solved the problem. Thanks for your interst/help.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
 |
 |
|
|
subject: Compiler can't find package
|
|
|