specifying classpath with -cp seems to have no effect

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, 99jonathan, imaqine

specifying classpath with -cp seems to have no effect

Postby Zman » Sun Feb 03, 2013 9:53 pm

Hello,

I have a somewhat complicated project that involves programs for no less than 4 machines. These programs have some functionality in common however, and I would like to package that functionality up separately, put it into a jar, and link the machine specific stuff to this jar. I can run the following commands without a problem, and create the shared jar file.

Code: Select all
nxjc src/zistack/MapBot/*.java -d bin
jar cvf lib/zistack.MapBot.jar bin/zistack/MapBot/*.class


But when I run the next command (it compiles the files for one of the machines), it fails spectacularly.

Code: Select all
nxjc src/zistack/MapBot/ZAP2/*.java -d bin -cp lib/zistack.MapBot.jar


Here are examples of the errors I am getting.

Code: Select all
Main.java:8: cannot find symbol
symbol: class CommEventListener
public class Main implements CommEventListener, DataEventListener{
                             ^
Main.java:8: cannot find symbol
symbol: class DataEventListener
public class Main implements CommEventListener, DataEventListener{
                                                ^
Main.java:35: cannot find symbol
symbol  : class CommEvent
location: class zistack.MapBot.ZAP2.Main
    public void handleCommEvent(CommEvent e){
                                ^
Main.java:43: cannot find symbol
symbol  : class DataEvent
location: class zistack.MapBot.ZAP2.Main
    public void handleDataEvent(DataEvent e){
                                ^
<More errors like this...>


I also get the above errors when I don't specify the classpath, as would be expected.

I am running on Arch Linux Arm, with openjdk6 and leJOS 0.9.1. Any help would be appreciated.

Zman
Zman
New User
 
Posts: 15
Joined: Mon Apr 14, 2008 1:24 am

Re: specifying classpath with -cp seems to have no effect

Postby skoehler » Sun Feb 03, 2013 10:11 pm

Zman wrote:
Code: Select all
nxjc src/zistack/MapBot/ZAP2/*.java -d bin -cp lib/zistack.MapBot.jar


Try options first, then filenames.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: specifying classpath with -cp seems to have no effect

Postby skoehler » Sun Feb 03, 2013 10:15 pm

Zman wrote:
Code: Select all
nxjc src/zistack/MapBot/*.java -d bin
jar cvf lib/zistack.MapBot.jar bin/zistack/MapBot/*.class


I think, the way you create the jar is pretty wrong. List the files inside the JAR with
Code: Select all
jar tf lib/zistack.MapBot.jar

If all the filenames start with "bin/", then it's obvious why javac doesn't find the classes. Classnames are mapped to filenames inside the JAR simply by replacing the "." with a "/". Create your JAR with
Code: Select all
jar cvf lib/zistack.MapBot.jar -C bin zistack/MapBot

and it should work.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: specifying classpath with -cp seems to have no effect

Postby Zman » Sun Feb 03, 2013 10:38 pm

Thanks, that was exactly it. Everything works fine and dandy now.

Zman
Zman
New User
 
Posts: 15
Joined: Mon Apr 14, 2008 1:24 am


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff