Include a file: Difference between revisions

→‎{{header|Processing}}: difference between .pde, .java., library, and jar imports
(→‎{{header|Processing}}: difference between .pde, .java., library, and jar imports)
Line 1,613:
 
=={{header|Processing}}==
Processing may include a file using a number of different methods.
Processing sketches ''automatically'' include include any Processing .pde or Java .java files in the sketch directory. All .pde files are concatenated together and processed as if they were one big file. Each .java file is compiled to a Java class and the class is automatically imported.
 
1. Processing sketches ''automatically'' include include any Processing .pde or Java .java files in the sketch directory. All .pde files are concatenated together and processed as if they were one big file. Each .java file is compiled to a Java class and the class is automatically imported.
Processing also supports the import keyword for explicitly including Processing / Java 8 libraries.
 
So, for a sketch:
<lang processing>import java.util.Map;
import g4p_controls.*;</lang>
 
MySketch/
MySketch.pde
one.pde
two.pde
MyClass.java
 
...the local files one.pde, two.pde, and MyClass.java are all automatically imported into MySketch by virtue of their extensions, without being explicitly referenced in MySketch.pde.
 
2. Java import statements may be used to import libraries from the path.
 
Processing also supports the `import` keyword for explicitly including Processing / Java 8 librarieslibrary files. This can be used to import standard part of Java 8, for example the Map class:
 
<lang processing>import java.util.Map;</lang>
 
It can also be used to import contributed libraries, which may be installed via PDE Contributions Manager or locally on the Processing Libraries path. For example, if the G4P library is installed, its files are then imported into a sketch with:
 
<lang processing>import g4p_controls.*;</lang>
 
3. Local Java JAR files may be added to the sketch /code subfolder, then imported with `import`. For example, if you have a file code/test.jar:
 
MySketch/
code/
test.jar
MySketch.pde
 
...and it contains a Java class file `foo/bar/Test.class`, then that can be imported from the file. The specific jar file name does _not_ need to be identified -- any resource in any jar file can be imported so long as you specify the in-jar path and class name in the import statement.
 
<lang processing>import foo.bar.Test;</lang>
 
=={{header|Prolog}}==