This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiler can't find package

 
Tim Nachreiner
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you compile Class1 first?
 
Tim Nachreiner
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Did you compile Class1 first?


Yes.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we shall have to do what Ralph Cook said earlier, and ask to see your folder structure.
 
Tim Nachreiner
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic