|
|
(14 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 javac'''</font>
| |
| | |
| Welcome to using Phidgets with Java! By using Java, you will have access to the complete Phidget22 API, including events.
| |
| | |
| Javac is a command line-based compiler for java programs that compiles java code into bytecode class files.
| |
| |{{TOC limit|2}}
| |
| |}
| |
| | |
| {{Language_-_Java_Intro|Windows|javac}}
| |
| | |
| ==Use Our Examples==
| |
| One of the best ways to start programming with Phidgets is to use our example code as a guide. Before we get started, make sure you have [[#Install Phidget Drivers for Windows | installed the Phidget drivers]].
| |
| | |
| | |
| Next, select an example that will work with your Phidget:
| |
| *{{SampleCode|Java|Java Examples}}
| |
| | |
| | |
| Copy phidget22.jar from the following location:
| |
| *C:\Program Files\Phidgets\Phidget22\phidget22.jar
| |
| | |
| | |
| Place both the example file and the phidget22.jar file in the same location. Your folder should now look something like this:
| |
| [[Image:Java_javac_folder.png|link= | center]] | |
| | |
| | |
| Open the command prompt at the folder location. Next, enter the following command in the command prompt:
| |
| <syntaxhighlight lang="java">
| |
| javac -classpath .;phidget22.jar example.java
| |
| </syntaxhighlight>
| |
| | |
| | |
| Finally, enter the following command to run the program:
| |
| <syntaxhighlight lang="java">
| |
| java -classpath .;phidget22.jar example
| |
| </syntaxhighlight>
| |
| | |
| | |
| [[Image:Java_javac.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 include the Phidget Java library, add the following line to your code:
| |
| <syntaxhighlight lang="java">
| |
| import com.phidget22.*
| |
| </syntaxhighlight>
| |
| | |
| You can now compile the file as shown in the [[#Use Our Examples|Use Our Examples]] section.
| |
| | |
| The project now has access to Phidgets.
| |
| | |
| ==Further Reading==
| |
| {{Language_-_Java_Further_Reading}}
| |