aspose file tools*
The moose likes Beginning Java and the fly likes Compiler can't find package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiler can Watch "Compiler can New topic
Author

Compiler can't find package

Tim Nachreiner
Greenhorn

Joined: Apr 28, 2011
Posts: 10
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: 10
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: 36599
    
  16
Did you compile Class1 first?
Tim Nachreiner
Greenhorn

Joined: Apr 28, 2011
Posts: 10
Campbell Ritchie wrote:Did you compile Class1 first?


Yes.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
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: 10
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: 36599
    
  16
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiler can't find package
 
Similar Threads
errors with the command line compiler
BeerExpert NoClassFoundDefError Issue (NOT COMPILE ERROR) - HF Servlets & JSP
Problem with Compiling java files in packages
servlet compiling errors
Package doesn't exists - error!!- How to resolve?