Make Java Executable

preview_player
Показать описание

I've been asked many times to show how to make a java program executable. It is actually very easy to make Java executable on any computer.

Рекомендации по теме
Комментарии
Автор

Thank you :) I have been programming for about 20 years and I've always enjoyed it. I never taught computer science outside of what I do online, but I've taught a bunch of other subjects for most of my life. I'm very happy that you are enjoying the videos. I'll be making games soon. Actually the last part of the Java tutorial is a game

derekbanas
Автор

Thank you for the compliment :) All I can say is when I sit down to make a video I never follow any of the rules you need to follow to maximize views / money. I just try to make the best video possible with my limited time. I'm glad you like them

derekbanas
Автор

Why does my computer never do the same things as the people's computers in the tutorials???

ChaseandFriends
Автор

You do not know how much you seriously helped me. I have looked all over the internet to kind out how to run a file by just double clicking but all they ever showed was just using Command Prompt/Terminal and that was the end of all their videos. This video explained so well, regardless of even using Terminal, because you also showed the equivalent for Command Prompt in Windows. Again, thank you so much and I will continue to see if there are any other further videos that you have to help me :)

NA-isoo
Автор

How is it that you are able to make a video as short as this is and still explain something that takes other people's videos two to three times as long. Keep up the good work.

TheDebare
Автор

Thank you :) You can email the files and they'll run on any OS. The great thing about Java is that it runs on any computer

derekbanas
Автор

Finding and fixing errors is pretty much what programmers do. In my Object Oriented Design tutorials I teach how to avoid errors all together, but just minimizing them is about the best you'll get.

derekbanas
Автор

I'm glad you figured it out. I'm very glad to have been able to help

derekbanas
Автор

for windows 8 while in the folder containing the files simply click "file" then "open command prompt" and an instance of cmd.exe will open with you already in the directory that your files are in.

roax
Автор

Derek, I love your tuts, you know your stuff and you speak very clear American English! Rock on Bro!

stormybear
Автор

For everybody who has a multi-folder / multi-package architecture and has problems getting his program to work, this is what worked for me, it is explained step by step:

1. create folder jar
2. inside, create folders source and classes
3. copy all your .java files into the source-folder
4. open the cmd in the source-folder (or navigate into it)
5. execute "javac -d ../classes *.java"
6. in the classes-folder there should be your package architectures created with folders

in my example I originally (before copying all of them into the source-folder) had a Main.java in the package assignment2.application and a Simulation.java in the package assignment2.simulation and also some other files in other packages
My folder-hirarchie looked like this:
.../Java
assignment2
application
Main.java
simulation
Simulation.java
model
*.java
profiling
*.java

after executing that first command I have:
.../jar
source
*.java
classes
assignment2
application
Main.class
simulation
Simulation.class
model
*.class
profiling
*.class

7. now create a file called manifest.txt in your editor (call it whatever you want, it's just usually called a Manifest-file, thats why I call it like that)
8. the file will be saved in the classes folder so that there are two objects in that folder (the folder "assignment2" and the txt "manifest.txt")
9. fill that file with the following: "Main-Class: assignment2/application/Main" and make sure to hit enter after the last letter so that a new line will start but that new line will stay empty, just to be clear because that is very important, it has to be a textfile with two lines, the above mentioned in the first line and the second line being empty
10. now open your command prompt again and navigate into your classes-folder so that when you type dir (or ls for linux/mac) it will show you the "assignment2"-folder and the "manifest.txt"-file
11. enter the following command "jar -cvmf manifest.txt Test4.jar assignment2/model/*.class assignment2/profiling/*.class
as you can see, I started the command by calling the jar.exe, next I typed in some letters for which you can get an explanation after just executing "jar --help", next I called our "manifest.txt"-file which tells the jar-programm which will be our Main-File later on, next I chose a name for our .jar-file and finally I listed all of our .class-files, I had to list every folder on its own because of our package-structure, I just seperated the listings with spaces and ended every listing (except for the first one calling "Main.class" to show an alternate way) with /*.class which tells the command to include every .class file it can find in that folder

12. finally we can launch our Test4.jar file with the command "java -jar Test4.jar"

I hope it helped

NiklasUnruh
Автор

Here is another quick solution Right click project -> export -> Runnable jar file -> For Launch configuration select the class with main in it -> Click finish
Tell me if that doesn't work. The error you are getting is happening because the directory structure is messed up in some way

derekbanas
Автор

THANK YOU!!

It's sometimes just the simple things that make all the difference.

Cpl.Cadaver
Автор

Yes you can do that, but 1 in 10 times it will throw a crazy error that it can't find a needed library. I'd say use Eclipse and if you get an error do everything manually. Either way it just takes a few seconds :)

derekbanas
Автор

To load images in an executable jar Image yourImage =
I hope that helps :)

derekbanas
Автор

Okay, guys don't forget the

<return> or <enter>

after "Main-Class: Filename" in the text file, or you will get some strange error.

bruceliebewilma
Автор

If you have your version working stick with it. I'm mainly hearing complaints from Python programmers in regards to Juno. Always feel free to ask questions

derekbanas
Автор

Thank you very much, this was a very simple and easy to understand. My only problem is remember at the end of day. :)

chefidin
Автор

Thank you! Can't wait to try this, at work right now...

davidkimery
Автор

Did you try to export with Eclipse? If so, your error is do to the 1 in 10 error group when exporting from Eclipse. That's why I showed how to do it this way. What I talk about in this video should work every time

derekbanas