how to add pi4j to CLASSPATH

605 views
Skip to first unread message

Felix Wehnert

unread,
Feb 20, 2013, 6:45:45 PM2/20/13
to pi...@googlegroups.com

I dont' want to compile and run everytime with "-classpath .:classes:/opt/pi4j/lib/'*' "

is there a way to add pi4j permanently to the classpath variable?

Peter Skopek

unread,
Feb 21, 2013, 4:26:34 AM2/21/13
to Felix Wehnert, pi...@googlegroups.com
Hi Felix,

what about to use Maven in your project? It is much more easier to
work with dependencies that do it manually.
See: http://maven.apache.org/
Here is POM file from my little project so you can have something to start with.

It is as simple as issue command: "mvn clean compile" or 'mvn
exec:java -Dexec.mainClass="com.example.Main"
[-Dexec.args="argument1"]'
when using maven exec plugin (http://mojo.codehaus.org/exec-maven-plugin/).

Believe me, it is really worth to spend one more hour to learn basics of Maven.


HTH

Regards,
Peter




<π/>
> --
> You received this message because you are subscribed to the Google Groups
> "Pi4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pi4j+uns...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
pom.xml

Robert Savage

unread,
Feb 23, 2013, 9:46:55 PM2/23/13
to pi...@googlegroups.com
TRY THIS:

Add the following CLASSPATH export to your environment file:

sudo nano /etc/environment

Here are the contents of my file:

JAVA_HOME="/opt/java/jdk1.8.0"
CLASSPATH=".:/opt/pi4j/lib/*"

Next, you need to allow the "sudo" command to retain the CLASSPATH environment variable when a command is executed via sudo.
Use this command to edit the file:

sudo nano /etc/sudoers

then add this line below the other "Defaults"

Defaults        env_keep +="CLASSPATH"

Now reboot.

sudo reboot

After rebooting, you should be able to compile (javac) and execute (java) without having to explicitly include the classpath command line argument.

This is working on my system.
Thanks, Robert
Reply all
Reply to author
Forward
0 new messages