|
|
(12 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| {{NoTitle}}
| | #REDIRECT [[Language - Java]] |
| {{Language_-_Java_Dev_Environment_Table}}
| |
| {|
| |
| |style="vertical-align:middle; width: 60%;"|
| |
| <font size=6>'''Language - Java'''
| |
| | |
| '''Windows with Eclipse'''</font>
| |
| | |
| Welcome to using Phidgets with Java! By using Java, you will have access to the complete Phidget22 API, including events.
| |
| | |
| Eclipse is an IDE used to write, compile, and run Java applications.
| |
| |{{TOC limit|2}}
| |
| |}
| |
| | |
| {{Language_-_Java_Intro|Windows|Eclipse}}
| |
| | |
| ==Use Our Examples==
| |
| One of the best ways to start programming with Phidgets is to use our example code as a guide. In order to run the examples, you will need to download and install [https://www.eclipse.org/downloads/ Eclipse].
| |
| | |
| | |
| Now that you have Eclipse installed, select an example that will work with your Phidget:
| |
| *{{SampleCode|Java|Java Examples}}
| |
| | |
| | |
| Next, create a new Java project:
| |
| [[Image:Java_eclipse_newproject_example.PNG|link=| center]] | |
| | |
| | |
| Click ''Next >'' and add phidget22.jar to your project as an external jar:
| |
| [[Image:Java_eclipse_addjar.png|link=| center]]
| |
| | |
| | |
| Finally, drag the example java files into the src folder that has been created for you and run the example:
| |
| [[Image:Java_eclipse_run.png|link=|center]]
| |
| | |
| | |
| {{Edit_the_Examples}}
| |
| | |
| ==Editing the Examples==
| |
| {{Language_-_Java_Editing_the_Examples}}
| |
| | |
| | |
| ==Write Code==
| |
| {{Language_-_Java_Write_Code}}
| |
| | |
| ==Setting up a New Project==
| |
| When you are building a project from scratch, or adding Phidget functionality to an existing project, you'll need to configure your development environment to properly link the Phidget Java library.
| |
| | |
| To begin, create a new Java project:
| |
| [[Image:Java_eclipse_newproject.PNG|link=| center]]
| |
| | |
| | |
| Click ''Next >'' and add phidget22.jar to your project as an external jar:
| |
| [[Image:Java_eclipse_addjar.png|link=| center]]
| |
| | |
| | |
| Create a new Class in your project:
| |
| [[Image:Java_eclipse_newClass_menu.png|link=|center]]
| |
| | |
| | |
| Name the class, and be sure to check the ''public static void main'' box.
| |
| [[Image:Java_eclipse_newClass.png|link=|center]]
| |
| | |
| | |
| Finally, to use the Phidget Java library, add the following import to your code:
| |
| <syntaxhighlight lang="java">
| |
| import com.phidget22.*;
| |
| </syntaxhighlight>
| |
| | |
| The project now has access to Phidgets.
| |
| | |
| ==Further Reading==
| |
| {{Language_-_Java_Further_Reading}}
| |