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

compiling problem  RSS feed

 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
created Person class in
D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
public abstract class Person{
private String name;
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
}

created Employee in
D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
public class Employee extends Person{
private int empID;
public void setEmpID(int EmpID){
this.empID=empID;
}
public int getEmpID(){
return empID;
}
}

this is not compiling saying cannot resolve symbol Person
where should i place it to make it compile
 
Sankara Rao Yadavalli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should contain dot (.) in the classpath. So that it recognises the classes which are available in the current directory. So that, you can compile your classes. If you use any editor to compile. Set the output path correctly.
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can u please tell how do it do it? plz
 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this
on the command promt
set classpath=%classpath%;D:\Tomcat4.1\webapps\foo\WEB-INF\classes
and then compile the file
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yaa i got it thanks
do i have to set the classpath everytime y so?
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first had to compile Person.java
javac -d . Person.java
then
set classpath=%classpath%;D:\Tomcat4.1\webapps\foo\WEB-INF\classes
then
javac Employee.java

what doesn -d and classpath do here
 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-d option just specifes where to put generated class files when u specify . tht means current directory (in dos) so tht -d . has no meaning in ure case and it has no connection with classpath
[ September 21, 2004: Message edited by: Santosh Jagtap ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, this is a forum for Servlets questions, unfortunately your question does not deal with Servlets. There is a forum called Java In General (Beginner) where this question should be.

I am going to move this thread there.

Mark
 
Mahesh Bhatt
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
The way given in the earlier post is correct way of giving the classpath/path. Pallavi, the classpath would exist only till the screen is open as soon as you cross out the screen, the classpath settings are lost and when you come back to work the other time you would be forced to type the class path command again. The best thing I would suggest you to do is :

1) open a text editor.
2) type your classpath here in the same way as given in the earlier post.
3) save this file as <filename>.bat (.bat extension is necessary).

that's it. Next time whenever you open the screen to work, you dont have to type the whole "set classpath ...." command, just type <filename>.bat, and the classpath will be set.

I hope this is what you wanted and it helps you .

regards
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do i have to set the classpath everytime y so?

No.

If your working directory were D:\Tomcat4.1\webapps\foo\WEB-INF\classes and you tried to compile from it but had the error you mentioned (after properly placing the Person.class file in D:\Tomcat4.1\webapps\foo\WEB-INF\classes\foo), then the problem is that your CLASSPATH doesn't include the current working directory as it should.

What's the result of running the following command?

echo %CLASSPATH%

If it's %CLASSPATH% this indicates that you don't have your CLASSPATH explicitly specified, which is fine. If this is the case, then you shouldn't have been having your initial problem.

If you want to explicitly specify your CLASSPATH for some reason, then you'll likely want to make sure it includes the current working directory, as specified by a period. For the steps to take to change your CLASSPATH environment variable, take a look at our FAQ on how to set the CLASSPATH.

Note that if your working directory were D:\Tomcat4.1\webapps\foo\WEB-INF\classes, the following command should also have worked.

javac -classpath . -d . Employee.java
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!