Language - Java Windows Javac: Difference between revisions

From Phidgets Support
No edit summary
(Redirected page to Language - Java)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[Category:Language]]{{NoTitle}}
#REDIRECT [[Language - Java]]
{|
|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 the example files 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 | 850px]]
 
 
{{Edit_the_Examples}}
 
==Editing the Examples==
{{Language_-_Java_Editing_the_Examples}}
 
==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.
 
First, copy phidget22.jar from the following location:
*C:\Program Files\Phidgets\Phidget22\phidget22.jar
 
Create your new project folder and java file, and place phidget22.jar in the same folder as your new project file. Your folder should look somehting like this:
[[Image:Java_javac_folder_new_project.png|link= | center]]
 
To use the Phidget Java library, add the following import to your code:
<syntaxhighlight lang="java">
import com.phidget22.*;
</syntaxhighlight>
 
Once you are ready to run your program, 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_new_project.PNG|link= | center]]
 
The project now has access to Phidgets.
 
{{Language Page What's Next}}

Latest revision as of 16:37, 15 March 2021

Redirect to: