Another Thread About Compiling

I'm having problems compiling some java source files, and after scouring these forums and doing countless google searches I can't seem to get this figured out.

The source files are divided into two packages: tic, and tic.event. As such, the directory structure is a folder called "tic" that contains several source files and a .jar file and another folder "event" which contains the remaining source files.

Here's the command I've been trying to use:

>javac -classpath /home/tic:/home/tic/event:/home/tic/pircbot.jar tic/*.java tic/event/*.java

And I'm getting a ton of undefined symbol errors:

tic/event/Message.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.Message

public abstract class Message extends TargetEvent {

^

tic/event/ChannelEvent.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.ChannelEvent

public class ChannelEvent extends TargetEvent {

^

tic/event/Finger.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.Finger

public class Finger extends TargetEvent {

^

tic/event/NickChange.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.NickChange

public class NickChange extends TargetEvent {

^

tic/event/Notice.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.Notice

public class Notice extends TargetEvent {

^

tic/event/Ping.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.Ping

public class Ping extends TargetEvent {

^

tic/event/Quit.java:6: cannot resolve symbol

symbol : class SourceEvent

location: class tic.event.Quit

public class Quit extends SourceEvent {

^

tic/event/UserMode.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.UserMode

public class UserMode extends TargetEvent {

^

tic/event/Version.java:6: cannot resolve symbol

symbol : class TargetEvent

location: class tic.event.Version

public class Version extends TargetEvent {

^

tic/Client.java:288: cannot resolve symbol

symbol : class ServerResponse

location: class tic.Client

log.Log(this.getName(), new ServerResponse(response, code));

^

tic/Client.java:364: cannot resolve symbol

symbol : class Time

location: class tic.Client

log.Log(target, new Time(sourceNick, sourceLogin,

^

tic/event/Message.java:22: cannot resolve symbol

symbol : variable super

location: class tic.event.Message

return super.Serialize(outgoing);

^

tic/event/ChannelBanEvent.java:21: cannot resolve symbol

symbol : method Serialize (java.util.ArrayList)

location: class tic.event.ChannelEvent

return super.Serialize(outgoing);

^

tic/event/ChannelKeyEvent.java:21: cannot resolve symbol

symbol : method Serialize (java.util.ArrayList)

location: class tic.event.ChannelEvent

return super.Serialize(outgoing);

^

tic/event/ChannelSetLimit.java:21: cannot resolve symbol

symbol : method Serialize (java.util.ArrayList)

location: class tic.event.ChannelEvent

return super.Serialize(outgoing);

^

tic/event/RecipientChannelEvent.java:21: cannot resolve symbol

symbol : method Serialize (java.util.ArrayList)

location: class tic.event.ChannelEvent

return super.Serialize(outgoing);

^

tic/event/Mode.java:20: cannot resolve symbol

symbol : method Serialize (java.util.ArrayList)

location: class tic.event.ChannelEvent

return super.Serialize(outgoing);

^

tic/event/Notice.java:20: cannot resolve symbol

symbol : variable super

location: class tic.event.Notice

return super.Serialize(outgoing);

^

tic/event/Ping.java:20: cannot resolve symbol

symbol : variable super

location: class tic.event.Ping

return super.Serialize(outgoing);

^

tic/event/Quit.java:20: cannot resolve symbol

symbol : variable super

location: class tic.event.Quit

return super.Serialize(outgoing);

^

tic/event/Topic.java:25: cannot resolve symbol

symbol : method Serialize (java.util.ArrayList)

location: class tic.event.ChannelEvent

return super.Serialize(outgoing);

^

tic/event/UserMode.java:20: cannot resolve symbol

symbol : variable super

location: class tic.event.UserMode

return super.Serialize(outgoing);

^

22 errors

Most of those classes (Time, TargetEvent) are in the tic.event package. Not sure why it's unable to resolve things like super and serializable though. Any insight would be greatly appreciated. Thanks.

[4994 byte] By [VP.a] at [2007-11-27 9:10:21]
# 1
post code inside of code tags.its good that you posted the errors, but the errors tell us nothing without a look at the code.
mkoryaka at 2007-7-12 21:51:38 > top of Java-index,Java Essentials,New To Java...
# 2

I can post the code...but we're talking about around 40 source files here.

I know the code works by the way...I'm trying to recompile the program on a new server. We copied the source and class files to the new server, but the application won't run (we're getting a NoClassDefFound error). So my thought was to try to recompile the program on the new server as runtime environment is a slightly newer version here.

So anyway...are you sure I need to post the code? What code would you be wanting to see specifically? I don't think posting all of it will be feasible.

VP.a at 2007-7-12 21:51:38 > top of Java-index,Java Essentials,New To Java...
# 3

Well for the last half of the errors, I'm pretty sure there is no variable "super" in any of your classes, and I'm pretty sure there is no class called "Serialize" anywhere in the API.

You realize the "super" keyword invokes the superclass' constructor, right?

Take a closer look at your code and at the error messages.

Just realized you can use super.serialize() for ingoing and outgoing streams.

You say this code worked before? If so, check your classpath.

Message was edited by:

Djaunl

Djaunla at 2007-7-12 21:51:38 > top of Java-index,Java Essentials,New To Java...
# 4

Ok, here is UserMode.java which should correspond with the last error for example:

package tic.event;

import java.util.*;

public class UserMode extends TargetEvent {

private String mode;

public UserMode(String sourceNick, String sourceLogin,

String sourceHostname, String targetNick, String mode) {

super("USRMD", sourceNick, sourceLogin, sourceHostname, targetNick);

this.mode = mode;

}

public String Serialize(ArrayList incoming) {

ArrayList outgoing =

new ArrayList(Arrays.asList(new String[] {mode}));

outgoing.addAll(incoming);

return super.Serialize(outgoing);

}

}

Once again, I know this program works, so I'm not sure if analyzing code syntax is going to help here...

EDIT: Ok, yeah I'm pretty sure its something with the classpath too.. but what should I be checking here?

Message was edited by:

VP.

VP.a at 2007-7-12 21:51:38 > top of Java-index,Java Essentials,New To Java...
# 5

Yea it's not about the code, my apologies. Judging by the error messages, it definitely looks like a classpath issue; it is not finding the appropriate packages. This is why it thinks super.Serialize is the wrong variable.method call, and other such things. The first half of the error messages, the package not found errors, point towards a classpath/package issue.

I recommend checking your build files. Make sure the directory and package structure is the same, and that the classpath structure is the same.

> EDIT: Ok, yeah I'm pretty sure its something with the

> classpath too.. but what should I be checking here?

If you're using Ant, check the build files. If you're using an IDE, check the build path or whatever the IDE uses. You just have to search around for awhile; classpath issues ALWAYS happen, but they're generally easy to resolve once you find the cause of the problem.

Message was edited by:

Djaunl

Djaunla at 2007-7-12 21:51:38 > top of Java-index,Java Essentials,New To Java...
# 6

Ok, I'm not using any build files. I've got the code up in Eclipse, but I'm not using that to compile anything either. I'm just trying to manually compile a bunch of .java files.

These are the paths to the java files:

tic package: /home/tic/<.java files here>

tic.event package: /home/tic/event/<.java files here>

additionally there is a jar file that I think is needed at /home/tic/pircbot.jar

So I guess if this is the incorrect method for compiling these files let me know, but otherwise I would think specifying the paths to these files as a classpath option for javac would be enough. Here is the command I used again:

>javac -classpath /home/tic:/home/tic/event:/home/tic/pircbot.jar tic/*.java tic/event/*.java

VP.a at 2007-7-12 21:51:39 > top of Java-index,Java Essentials,New To Java...
# 7
Try using -cp instead of -classpath, and trying adding the current directory (.) to the classpath.
Djaunla at 2007-7-12 21:51:39 > top of Java-index,Java Essentials,New To Java...
# 8

-cp is not recognized as a valid option. Maybe the java version is too old? It's 1.4.2_15

Adding the current directory didn't resolve the problem:

javac -classpath .:/home/nwhorton/tictest/tic:/home/nwhorton/tictest/tic/event:/home/nwhorton/tictest/tic/pircbot.jar tic/*.java tic/event/*.java

VP.a at 2007-7-12 21:51:39 > top of Java-index,Java Essentials,New To Java...
# 9

> -cp is not recognized as a valid option. Maybe the

> java version is too old? It's 1.4.2_15

>

> Adding the current directory didn't resolve the

> problem:

> javac -classpath

> .:/home/nwhorton/tictest/tic:/home/nwhorton/tictest/ti

> c/event:/home/nwhorton/tictest/tic/pircbot.jar

> tic/*.java tic/event/*.java

Hrm hrm hrm. I'm running out of ideas. -cp only works with 1.5+ I believe.

I assume you are compiling from the directory above tic?

Wait wait wait. Your classes are defined to be in the package "tic.<whatever>"? If so, you need to set the classpath to the directory ABOVE tic. Try:

javac -classpath .:/home/nwhorton/tictest:/home/nwhorton/tictest/tic/pircbot.jar tic/*.java tic/event/*.java

Or whatever classpath goes one directory above your packages.

Djaunla at 2007-7-12 21:51:39 > top of Java-index,Java Essentials,New To Java...
# 10
Still no luck. Am I correct to separate the paths in the classpath with colons, or should they be semicolons? When I switch to semicolons I get a permission denied error on the pircbot.jar file
VP.a at 2007-7-12 21:51:39 > top of Java-index,Java Essentials,New To Java...
# 11

> Still no luck. Am I correct to separate the paths in

> the classpath with colons, or should they be

> semicolons? When I switch to semicolons I get a

> permission denied error on the pircbot.jar file

On UNIX: colons.

On WINDOWS: semicolons.

If you get permission denied, that's probably because of file permissions. Make sure you're allowed to read from it.

Djaunla at 2007-7-12 21:51:39 > top of Java-index,Java Essentials,New To Java...
# 12
Hi,I'm curious as to the resolution of this problem. Did you figure it out?Thanks
Djaunla at 2007-7-12 21:51:39 > top of Java-index,Java Essentials,New To Java...
# 13

Sorry, I should've replied to this when this was resolved, but I was already working 20 mins past when I should've left so I was rushing out the door :)

The problem was that one of the source files was missing. I still had the classpath wrong, but it should've worked after you realized I was one directory too high. When it still didn't work I compared the list of source files to the list of class files and realized I was one file short on the sources. Pretty dumb mistake, but hard to notice with so many source files.

I blame sftp for not letting me use * to transfer the files...I had to transfer each source individually and must've skipped one.

Anyway, thanks for working with me...as usual it was my mistake that was causing the problem :)

VP.a at 2007-7-12 21:51:45 > top of Java-index,Java Essentials,New To Java...