| gclib 424 Communications API for Galil controllers and PLCs |

java.md
1 # Java {#java}
2
3 gclib uses the venerable
4 <a href="https://java-native-access.github.io/jna/4.4.0/javadoc/overview-summary.html#overview.description">
5 Java Native Access (JNA)</a> library to simplify integration into the Java
6 Native Interface (JNI).
7
8 \attention This is the initial version of the the gclib Java wrapper. As such,
9 GclibJava ships as source files, not the compiled jar files. All functions
10 are subject to change in future releases of gclib. Java hackers with
11 recommendations on how to make this library better are encouraged to email
12 softwaresupport@galil.com. Somebody has to teach those Galil Java noobs what's
13 what.
14
15 ## Windows
16
17 The following instructions were performed with 64 bit Windows 7 on
18 <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-142931.html">
19 Oracle NetBeans IDE 8.2 and Java 1.8.0_131</a>.
20
21 For brevity, these instructions assume the default gclib installation location
22 of "C:\Program Files (x86)\Galil\gclib".
23
24 ### Step-by-Step
25
26 1. Install <a href="http://galil.com/sw/pub/all/doc/gclib/html/windows.html" target="_blank">gclib</a> with 64 bit binaries (default install).
27 2. Install 64 bit NetBeans and Java, <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-142931.html" target="_blank">jdk-8u131-nb-8_2-windows-x64.exe</a>.
28 3. Launch NetBeans.
29 4. Create a new application.
30 1. File | New Project...
31 2. Under *Categories*, select *Java*.
32 3. Under *Projects*, select *Java Application*.
33 4. Click *Next*.
34 5. Type `GclibTest` for the *Project Name*.
35 6. Note the location of the *Project Folder*.
36 7. Uncheck *Create Main Class*
37 8. Click *Finish*
38 5. Open the *Project Folder* as noted above.
39 6. Open the *src* directory in the *Project Folder* location.
40 7. Copy the whole directory *C:\\Program Files (x86)\\Galil\\gclib\\examples\\java\\gclibtest* to this directory.
41 8. Copy the whole directory *C:\\Program Files (x86)\\Galil\\gclib\\source\\wrappers\\java\\gclibjava* to this directory.
42 9. Create a directory at `c:\jna\`.
43 * Another directory may be chosen. The purpose of this directory
44 is to hold jna's *jar* binary for the Java classpath.
45 10. Download a copy of *jna.jar* to the new directory.
46 * <a href="https://github.com/java-native-access/jna#download" target="_blank">https://github.com/java-native-access/jna#download</a>
47 * This example uses *jna-4.4.0.jar*.
48 11. In the NetBeans *Projects* tab, expand *GclibTest*.
49 12. Right-click on *Libraries* and choose *Add JAR/Folder...*.
50 13. Navigate to the *jna.jar* saved above. Click *Open* to add *jna.jar* to the classpath.
51 14. In the NetBeans *Projects* tab, right-click on *GclibTest* and choose *Properties*.
52 15. Choose the *Run* item out of the *Categories* options tree.
53 16. In the *Main Class* text box, type `gclibtest.GclibTest`. Click *OK*.
54 17. In the NetBeans *Projects* tab, expand *GclibTest | Source Packages | gclibtest*.
55 18. Double click *GclibTest.java*, and find the line containing `gclib.GOpen`.
56 19. Update the address for the desired hardware.
57 20. Choose *Run | Run Project (GclibTest)* or hit the `F6` key to run the application.
58 21. The appplication output will print in the NetBeans *Output* window.
59
60 ### Documentation
61
62 The GclibJava class has helpful documentation for developing a Java application.
63 Use the following instructions to create the Javadoc.
64
65 1. In the NetBeans *Projects* tab, right-click *GclibTest*.
66 2. Choose *Generate Javadoc* to create the documentation and open it in the
67 system's default browser.
68
69