Java Basics – Runnable Jar With Source Code

>>Hi. My name is Margaret. In this video I’m want to
show you how you can create a runnable Char file that
includes the Java code. Here I created a simple GUI
application that allows me to play the memory game and I called my java
project assignment Memory. So I’m going to select it. I right click and
I choose export. And when I export I have
different options here, I’m going to my java option and in my java option
I have either char file or runnable char file. Now there’s a temptation to click the runnable
char file here but we are not going to do that. If I choose runnable char file
then I will no longer be able to specify that I need
my source code included. So I have to go to my
first option, char file. I click next and because I
selected assignment memory already, Eclipse remembers that this is the project the one
I have included in my char file. It also assumes that I want to
export the generated class files and resources but in
addition I want to make sure to check this check box here, it says Export java
source files and resources. This check box allows
me to specify that the java source code
needs to be included. Here I can browse to a
special place where I want to store my char file or give
it a special name, in my case I like to have it in C, Temp, and I want to have
it named memory char. Notice how finish
is already blue. There’s a temptation to click on
it but you don’t want to d that. If I click finish at this point,
its not going to be runnable. So I need to go to next
because I need to make a change in the manifest, so I go
to next which allows me to specify some packaging
options we don’t want to do that. So I keep going next
one more time. Now it says char
manifest specification. That’s where I can specify that
my char file should be runnable. The way I do that is by
letting my char file know where the main method is. Once the char file knows which class includes the main
method it can start execution right there. So, rather than just typing
in a path we can just go to my browse button and it
gives me the different options of classes that include
a main method. In my case there is only one
possibility the only class that includes a main
method is in GUI memory. So that’s easy. That’s of course the one
I am going to select. Here it gives me
memory dot GUI memory and now I am ready
to say finish. At this point I show
you my folder. A file memory dot
char has been created. I’m going to run it now. I can just double click here and
it opened up my second screen. So I push it over, here is my
memory game and I can just click on the different images
and play my memory game. Another way to run a runnable
char file is in the console. So here I say Windows
R to start my console. I’m going to say okay. Open the window right
here, we push it over and I’m navigating
to my Temp folder. So, we are going to Temp,
we are listing our files, it includes memory, the char and I can just say Java
dash char memory dot char. Once again it opens
on a different screen and I can play my
memory game again.

Tags: , , , , , , , , , , , , , ,


  • DragonSlayer6710 says:

    Thank You! Literally the only source I could find that explained this clearly and easily! 😀

  • jvsnyc says:

    This is a great video. There's so many thousands (tens of thousands) of nice Java Applets that were written over years that we are kinda sorta losing access to after Java 8. Figuring out how to convert them to something that will still be supported going forward is sort of interesting to me…this looks like it could be part of some solutions.

Leave a Reply

Your email address will not be published. Required fields are marked *