aspose file tools*
The moose likes Beginning Java and the fly likes Compiling java file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiling java file " Watch "Compiling java file " New topic
Author

Compiling java file

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
This is a pretty silly problem.
I am trying to complile the Person.java file which creates the Dog variable ( Dog class is compiled)
From what i know , the memebers from with in the same package automatically gets imported , however here, i have tried everything by importng and setttng the classpath but still get the same error where "class Dog" symbol cannot be found.- the variable Dog, and the methods getDog() and setDog() cannot be found








The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
Moving to a more appropriate forum, since the question has nothing to do with the SCWCD exam (which this forum is about).


Ping & DNS - updated with new look and Ping home screen widget
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Without knowing how you're trying to compile it, the directory layout, etc. it'll be tough to help.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Here it is..

My class files are stored in classes/foo directory
and my source (java) files are stored in src/foo directory

This is the file structure:

C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/Testing/web-inf/classes/foo/Dog.class

C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/Testing/web-inf/src/foo/Dog.java
C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/Testing/web-inf/src/foo/Person.java

And at the command prompt its :
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Testing\WEB-INF> javac -classpath "C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/Testing/web-inf/classes" -d classes src/foo/Person.java
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Why are you putting your work into a Program Files directory? Leave that for installed code, or code Tomcat creates for itself.

This is what I suggest.

Create your own java_work or similar directory.
  • Open command prompt. This will default to "My Documents"
  • Create a folder with "mkdir java_work" You now have this directory in "My Documents"
  • Navigate there with "cd java_work"
  • mkdir foo
  • Move your Dog.java and Person.java files into the new foo directory
  • Compile with "javac foo/Dog/java" then "javac foo/Person.java"
  • There are many other ways to do it.

    By the way: the import statement in Person is unnecessary. Also you can probably say Dog rather than foo.Dog.
    Nabila Mohammad
    Ranch Hand

    Joined: Nov 05, 2007
    Posts: 661
    Thanks.
    I got it!
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36514
        
      16
    Well done
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Compiling java file
     
    Similar Threads
    EL usage
    EL doesn't work
    can't able to compile javabean file
    EL Execution Problem
    El property not found problem