Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Bean Sub Classes  RSS feed

 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright...

I am creating a bunch of beans.... magic beans?

anyway

I have 2 classes

Parameters.java


and
Contacts.java


both of these files exist in
myapp/WEB-INF/classes/com/

I get an error when compiling Contacts.java



how can you pull from another class succesfully
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the classes directory.

Javapedia: Classpath
How Classes are Found
[ May 05, 2005: Message edited by: Steve Morrow ]
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. You probably will have an easier time if you don't store your source tree in the /WEB-INF/classes directory...
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where should it be instead?
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where should it be instead?
Your source code? Wherever you want. But I like to keep the source and compiled classes separate; it makes clean builds much easier/less dangerous.
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do I need to reset my class path for every application?
and if so how?
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok...

I got it to work

what I had to do was compile it from

/webapp/classes/

javac com/Parameters.java
javac com/Contacts.java

This worked...

Why? do I have to compile all packaged classes from the reference of the classes folder?
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Todd:
do I need to reset my class path for every application?
and if so how?
I don't recommend setting a system classpath at all. I recommend specifying the classpath as an argument or within the context of your application (IDE setting, etc.).
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what I had to do was compile it from

/webapp/classes/
Yeah, that's kind of what I pointed out...

This worked...

Why? do I have to compile all packaged classes from the reference of the classes folder?
It worked because that's what the compiler expects. Check out those links I posted, and get yourself familiar with how the classpath operates. It'll ease many future headaches, I guarantee.

Also, if you haven't yet heard of Apache Ant, you'll want to do yourself a favor and learn about it, quickly.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!