Forums Register Login

Compiling java file

+Pie Number of slices to send: Send
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






+Pie Number of slices to send: Send
Moving to a more appropriate forum, since the question has nothing to do with the SCWCD exam (which this forum is about).
+Pie Number of slices to send: Send
Without knowing how you're trying to compile it, the directory layout, etc. it'll be tough to help.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
    +Pie Number of slices to send: Send
    Thanks.
    I got it!
    +Pie Number of slices to send: Send
    Well done
    These are the worst of times and these are the best of times. And this is the best tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 4050 times.
    Similar Threads
    can't able to compile javabean file
    EL Execution Problem
    EL usage
    El property not found problem
    EL doesn't work
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 18, 2024 20:01:54.