|
|
(16 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'''
| |
| | |
| '''MacOS 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|macOS|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 macOS | installed the Phidget drivers]].
| |
| | |
| | |
| Next, select an example that will work with your Phidget:
| |
| *{{SampleCode|Java|Java Examples}}
| |
| | |
| | |
| Place both the example file and the phidget22.jar file in the same location. Your folder should now look something like this:
| |
| [[Image:Java_mac_javac_folder.png|link=|center]] | |
| | |
| | |
| Open the terminal at the folder location. Next, enter the following command:
| |
| | |
| <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_mac_javac_run.png|link=|center]]
| |
| | |
| | |
| {{Edit_the_Examples}}
| |
| | |
| ==Editing the Examples==
| |
| {{Language_-_Java_Edit_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.
| |
| | |
| {{Language_-_Java_Further_Reading}}
| |