Trouble using pi4j


16 posts
by fillup » Sun Apr 23, 2017 7:14 pm
Hey I haven't programmed in java for raspi before. I'm trying to write a program for the raspi, using a windows laptop, eclipse and the pi4j project. I downloaded the pi4j zip file, but have no idea what to do with it. I could use step by step instructions on how to include pi4j into my project, so I can access the gpio pins. I dont want to write my program on the pi. I want to write it on my laptop and then deploy that executable to the pi. Please help!
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by DougieLawson » Sun Apr 23, 2017 7:41 pm
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 28379
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by fillup » Sun Apr 23, 2017 7:51 pm
That doesn't help at all. Can't resolve source. As I said in the original post, I need step by step instructions, not example code.
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by DougieLawson » Sun Apr 23, 2017 8:04 pm
Read the whole of that fine web page (RTWOTFWP).

That web page has all the instructions you need. Scroll down to the bottom where it tells you all about running javac and java with the pi4j.jar file.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 28379
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by fillup » Sun Apr 23, 2017 8:07 pm
If it helps you better understand my problem here is a screen shot
Attachments
pi4jtrouble.PNG
screen shot
pi4jtrouble.PNG (51.97 KiB) Viewed 521 times
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by DougieLawson » Sun Apr 23, 2017 8:14 pm
What on earth is that?

Get a command line running in LXTerminal.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 28379
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by fillup » Sun Apr 23, 2017 8:16 pm
Just because you say it's helpful, doesn't make it helpful. I didn't see anything about running javac. Further, I'm not using java from the command line. I'm using eclipse on a windows 10 laptop, as I said in my original post. My problem is that eclipse doesn't know what pi4j is. This is what I need help with.
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by fillup » Sun Apr 23, 2017 8:21 pm
No, I'm not going to get a linux terminal running on my windows 10 laptop. The equipment I have to work with is.... a windows 10 laptop. Not a linux based computer. I'm not going to run an emulator. I simply want to know how to make eclipse recognize pi4j. THAT. IS. IT. If you can actually help me, great. If you're going to not read my post and then assume I can't use google, then please, don't reply. That goes to everyone. Either help me with what I asked for help with or don't waste your/my time.
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by DougieLawson » Sun Apr 23, 2017 8:45 pm
You'll need to go and ask your question on an Eclipse forum for Eclipse support. You do realise you gave no clues you weren't logged on to a RPi with a stock Pixel desktop when you posted your initial question.

Get a copy of PuTTY on Windows and you can run stuff on your Raspberry.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 28379
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by Martin Frezman » Sun Apr 23, 2017 8:46 pm
Dougie is not going to like your attitude, my friend.
If this post appears in the wrong forums category, my apologies.
Posts: 754
Joined: Mon Oct 31, 2016 10:05 am
by fillup » Sun Apr 23, 2017 8:51 pm
LOL I could care less. If people are too dumb to read my entire post, then they get what they get. Every time I ask for help in this forum, I get some hot shot who doesn't read my post and gives me the same material I found myself on google. It's rather annoying. I wish I didn't have to be rude, but it's kind of hard to remind people to read my post without being rude. I'm not sure why people think they can help without first reading the question. I'm sure people on here get testy when new members don't read the rules before posting, so maybe you can understand my frustration with people responding to my question without actually reading it.
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by Martin Frezman » Sun Apr 23, 2017 9:01 pm
Yeppers.

But you don't get your post count up over 27000 by reading what you're responding to. There's only so many hours in a day, ya know.
If this post appears in the wrong forums category, my apologies.
Posts: 754
Joined: Mon Oct 31, 2016 10:05 am
by fillup » Sun Apr 23, 2017 9:11 pm
Touche. Now that we've fully discussed the reason that the proposed solution is no solution for me, can we move on to what this post is about? I'm still looking for the most basic of help. Can anybody explain how to get eclipse to recognize the pi4j library??
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by fillup » Sun Apr 23, 2017 9:34 pm
In case any one is interested, I figured it out myself. It had been quite some time since I had to add external JAR's to a project, but this was the answer. In the pi4j zip file, there is a folder "lib". This folder contains all the jar files you want to add. Here is a link regarding how to add JAR files to the build path. http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse
Posts: 21
Joined: Mon Nov 21, 2016 1:09 am
by DougieLawson » Sun Apr 23, 2017 9:34 pm
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 28379
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by JohnAntonioCollins » Mon May 01, 2017 11:10 pm
Maybe I'm repeating what's been said, but generally you need to add your .jar or library to your project path. Then your project can use it. So to answer the OP, download pi4j, put it in your project path, and then your IDE will "see" it. Specifics vary depending on your developing environment. Your import statement on the screenshot looks correct to me at a glance.
Posts: 4
Joined: Mon May 01, 2017 10:45 pm