Subtitles section Play video
[BELL DING]
Hello, and welcome to a new series
about building a processing library in Java.
So if you've ever wanted to learn a little more
about Java programming, and how Open Source works,
and how you can contribute your own code
as a library to some other platform,
this is the place for you.
I started working with processing in 2003, which
is some number of years ago.
It's too many years ago.
I can't possibly do that math.
And one of the things that I first
did when working with processing was contribute libraries to it.
And you can see here I'm scrolling
through the processing libraries page.
There are libraries for all sorts of categories.
I'm just going to go here under video and vision, for example.
And we'll see there's a library for using the PSI
camera for doing OpenCV.
Oh, look at this one for the connect.
And it's really not kept up to date.
There's a lot of wonderful libraries here, BlobDetection.
This is a really useful one.
I have some videos about doing BlobDetection processing
with your own code, but you could use a library for it.
So maybe you've used processing.
Maybe you've used a library before.
How would you make your own library?
This is what this video is about.
I have to admit something to you.
I have not actually done any research or practice
before I'm beginning this right now.
I have made processing libraries.
But I haven't really made one in a while.
So a lot of the series will also be me figuring it out as I go.
And hopefully everything works just fine.
It's somewhat of an ancient medieval art,
how to built a compilation of Java classes
to insert as a processing library.
And a lot of the stuff--
you noticed I've been doing Java scripts on the channel
these days.
But maybe after I do this I'll come back and show you
how to make your own JavaScript library as well.
So the very first thing that we need to do
is go to the processing library template under the processing
GitHub organization.
And you'll notice something.
It actually says template here.
And there's this little button here, Use This Template.
This is a new feature of GitHub.
I don't know how new it is.
Maybe it's been there for a while.
But I've actually never used this feature up
until right now.
A lot of times when you're using GitHub-- maybe
you're just trying to find some code,
and you're clicking around, you copy and paste it,
or maybe you're even ambitious enough to clone or download.
So cloning is a process of taking this repository
and cloning it, say, to another, to your local computer,
your laptop.
I'm actually going to do that a little bit later in this video.
Downloading would just be downloading the code.
There's this process of forking a repo, which
is kind of creating a version of it that is linked back
to the original version.
But this is a scenario.
This is a rare scenario where what I want to do
is build an entirely new project.
It's not really related to this.
It's related to this in that this is my starting point.
But there's no reason for what I want
to build to be a fork of the template
because I am not contributing back to the template.
If there was an issue with something
wrong in the template, then I would
want to make a fork to fix the thing that's in the template.
But I just want to start from it.
That was a very long explanation for me just basically pressing
this button.
So I'm going to press this button.
I'm actually going to switch this to coding train
because I would like this library that I
make to be a community project that people could submit to.
I could do that under Schiffman as well.
But this is a coding train processing library.
I'm going to call this open simplex noise library--
I'll call it for processing.
Let's call it for processing.
So that's going to be the name of the repository.
This is a new, a processing for open simplex noise.
And I want to make it public.
And I want to create the repository from the template.
I love this.
I love that this is a new repository, a new project.
But GitHub is being thoughtful about this
and crediting back where it was generated from.
Now, what is the next step?
The next step is now I want to work with this,
and update the code, and change it around, and put my stuff,
my open simplex noise stuff in it.
And by the way, you might be wondering
what is open simplex noise?
So I have a whole video about what that is.
It's not really important right now.
The point is how to make the library.
But I want to make it in the context that would be useful.
So I'll come back and talk more about open simplex noise.
And we'll look at some examples with it
as we get a little further along.
So I'm going to click Clone.
I'm going to copy this.
I' going to go to my terminal application.
I'm just in the desktop.
I'm going to say get clone.
And I'm going to clone this particular repo, which
will now download everything to my computer.
I'm just going to then open up that repo.
Oh, no I'm not.
I'm not.
I was about to open up that repo.
And I'm doing it right now in Visual Studio Code, which
would be fine, because then I could kind of look
at what's in there.
There's a hello library, job template and stuff.
But no, no, no.
Close all this.
This is not what I want.
This is a very momentous occasion.
This might be the first time I need to use a Java development
environment.
I'm sure there's some magical way
I could make Visual Studio Code do what it is I want to do.
But I want to do this with a Java development
environment, namely Eclipse.
This is the Eclipse foundation website
where you can download and install Eclipse.
And I'm going to do that in a moment.
I should mention also that a lot of people in the chat
are saying, oh, using IntelliJ.
I like that better than Eclipse.
I don't know.
Maybe it is better.
Maybe it's worse.
Who knows?
Who cares?
I'm just going to use Eclipse.
It's the only one I've ever used,
and I want to have at least one thing here that I
don't have to learn that's new.
But maybe I can come back and show IntelliJ at some point,
or one of you can make your own video
about doing the same thing with IntelliJ, and I can link to it.
Let's download Eclipse.
I'm going to get this most latest version.
I'm going to download the 64-bit.
This link looks good.
Eclipse, much like processing, is a non-for-profit foundation.
And you can donate.
All right, once you've downloaded it,
you're going to get this eclipse installer.
And then you've got to choose what you want here.
I want eclipse ID for Java developers, I think.
That's what I'm doing.
So I'm going to install it here.
Hit accept.
And here we go.
All right, I've downloaded, installed it.
I'm going to launch it now.
I also should mention that I think the processing library
template is designed for use with Eclipse.
It's creating a workspace, which is similar to a processing
sketchbook.
All right, here we go.
I have Eclipse now.
Now I'm going to have to do some work to fix the font sizes.
I realize if you're watching this
you can barely see anything.
But right now, I'll just use Zoom for a second.
These are my options.
I could create a new project, a java project,
a sort of general project.
But what I want to do, I am pretty sure,
is import a project.
So I'm going to click on Import.
And then these are all of my options.
Oh, look at this.
It even has a Git.
So I actually could probably import it from Git
but I think I can just do general existing.
This is what I want.
I think I want existing project into workspace
because the processing library template is an existing Eclipse
project.
So then I'm going to hit Next.
And I want to find that directory,
which is just on my desktop called Open Simplex
Noise For Processing.
I'm going to hit Open.
And you can see.
Look at that.
Oh, interesting.
It's called processing library template.
So there's probably somewhere that there's a name for it
that I might want to rename.
I'm going to worry about that too much right now.
I'm just going to click now Finish.
Finish.
And OK.
There we go.
This is looking promising.
Oh, I have a red x.
But you can see now this is an Eclipse project.
It's got all of the files here in this directory tree.
There's a data folder, an examples folder, a lib folder,
a resources folder.
I may have to get into what's in those things.
But the most important one right now is the source folder.
I'm going to click on that.
And we're going to see.
This is the Java file.
It's not a PDE file, not a processing development
environment file.
It's an actual proper Java file.
This is the file that I'm going to need to work with.
Let me quickly mention that under the Preferences,
under General Appearance, you can
change the theme to dark mode, which I'm doing right now.
PApplet cannot be resolved to a type.
The import processing cannot be resolved to a type.
So this is because this particular project
means as a dependency the processing core library itself.
So there are a couple different ways
that I could tell this project, my processing library,
about the processing core library.
And I'm going to show you the easiest
way to do that right now.
I should mention, however, that all of this, all of what
I'm awkwardly kind of stumbling through
is actually here as instructions on the read me.
And the step that I'm looking to do right now
is adding core dot jar or other jar files to your class path.
So the idea of a class path is a very important concept
in Java programming.
It is the path where all of your dependencies
live, all of the classes that your project depends
on live, the path to your classes, the class path.
So what I want to find is core dot jar.
That's a bundle jar file.
It's like a zip file that has all of the processing Java
classes in it.
And there's a variety of different ways
that I can find it.
But if I happen to have processing installed
on my computer, on the Mac-- and you can find this similarly
on Windows or Linux--
I can actually just right click on here
and go to show package contents.
A Java application is actually just a directory of files.
It's kind of the operating system is hiding that for you.
But I can go here under Java.
And look at this, core dot jar.
Now, I might find that I need other dependencies eventually.
But right now, I just want core dot jar.
So what I'm going to do is I am going
to copy that into my project just by dragging it over.
I'm just going to put it in the root directory.
Maybe there's a better place to put it.
Oh, I could link to the file.
Huh.
There might be different reasons why you might
want to do one or the other.
I'm going to stick with copy, just
so that I know it comes in.
So I could see core dot jar is there.
I still have my errors though.
But what I want to do now is I'm going
to right click core dot jar.
And I'm going to go to build path.
Build path is essentially another sort
of term for class path.
And I want to add this to the build path.
So we click Add to the Build Path.
And then voila.
All of those errors go away.
It knows what PApplet is because PApplet
is part of processing dot core.
PApplet is the base class for every sketch
you write in processing.
Almost finished this first part now.
I'm just about ready to actually start
doing the coding of the library itself.
This first part was really just to set up the project itself.
But I want to do a few more cleanup things.
Number one is it shouldn't be called
processing library template.
So I'm going to right click here and go to refactor, rename.
[MUSIC PLAYING]
And I'm going to change the new name to open
simplex noise for processing.
Looking more closely at the instructions,
I've discovered actually that the point of this lib folder
is this is where other dependencies should go.
So I'm actually just going to move this core dot
jar file there.
I think the project--
oh, now it's complaining at me.
So you should have copied it in there in the first place.
But now what I'm going to do is I'm
going to right click on the project, go to build path,
configure build path, and this is now-- it's confused.
This core dot jar file is now missing.
I'm going to hit Remove.
And then I'm going to do apply and close.
Then I'm going to just go back to this
and go to build path and add back to the build path.
OK.
So now I have my project set up.
There are a few last remaining steps we need.
We want to get to the point where I can build the library.
I want to see the build successful message.
And I'll be done with this first video in the series.
So what I need to actually do is I
need to look for a file called build dot properties.
And this is going to be in the resources folder of the Java
project.
So let's go back to Eclipse, go here under Resources,
build dot properties.
That's what I want there.
Oh, I have never seen anything like this.
So it appears that eclipse has added
a GUI for build dot properties.
But I'm actually going to click here
so I can look at the actual text file.
And this is-- this is important.
So where is my processing sketchbook?
I'm going to open up processing to make sure this is right.
I'm going to go to processing preferences.
And we can see users coding train documents processing.
That's where the sketchbook is.
Great.
That's user home documents processing.
OK.
Class path local location, this is the next setting
that I need to change.
And I need to make sure it points to the processing core
library.
So it's been a lot of effort getting that core
dot jar file into my project.
So I now I also need to point from build dot properties.
So there's a variety of places I could
point to the processing application, which
for me is on the desktop.
But it might be your applications folder.
So it would be different on Windows or Linux.
I think, for me, what might actually
be easiest is just to comment this out and point to where
this actual project is.
So this actual project is here on
my desktop, desktop open simplex for noise processing.
So I can put that in here, paste that here.
Then there's a file called lib for library
where core dot jar is-- not a file, a directory.
So I should just put that in here and hit Save.
That's good.
Class path local include core dot jar.
And then class path libraries location
is sketchbook dot location libraries.
So all this is the same.
Target version 1.8-- that should be fine.
All this stuff is fine.
Project name-- there's more stuff I should change.
So I'm just going to say open simplex noise.
I'm going to say open simplex noise for processing.
This is not super important.
I can fix this stuff up later.
But let's just do some of this right now.
And I don't have a url yet.
And there's categories.
Let's just put it in other.
Actually, is there math math?
I'm doing all of these now.
All right, I'm going to fix this up later.
I'm going to put the rest of these--
but you could see that there's lots of other things
that I can put in here.
But I'm going to leave this all out.
I'm going to hit Save.
And I'm going to go to the next step.
The next step is to compile the library using Ant.
What is Ant?
Ant, or Apache Ant, is basically a build system for Java.
It's maybe somewhat ancient, but it's
what's used by the processing library template.
So if I go back to Eclipse--
so to be able to see Ant, I need to go
to Window, Show, View, Ant.
And you can see the little icon of the ant.
Let's click that.
And now I should have somewhere--
oh, Ant, now I see it.
The next step is to take this build dot xml file,
and drag it over to here, and we can see.
There it is, processing library, open simplex noise
for processing.
And I can click this, and do Run As Ant Build.
Run As Ant Build.
OK, now we say a little prayer to the Ant god.
And we-- [DRUM ROLL] --run that.
Ha.
[TADA SOUND] We built the processing library.
Build successful.
Look at this.
I can open up processing.
I'm going to go to Sketch Import Library.
Look at this, open simplex noise for processing.
The library is there.
Now, it's saying import template dot library.
And there's no code for me to actually use.
But I now have the processing library building.
And I can start writing the code.
So in a way, this was really the hardest part.
The next stuff that I want to do is
going to be quite simple by comparison.
It's really just adding the code, adding the examples,
building the library, and publishing it.
So that will come in the next video, or two, or three,
and I'll see you there.
Thanks for watching this.
We built a processing Java library.
[BELL DING]
[MUSIC PLAYING]