How can I transform a .jar file to a .bat file?



Today we want to show you how to convert a ready java file to a batch file on Windows so that we can run the finished java program without using a development environment (Eclipse, NetBeans).


Let's just imagine a program.
Today we want to show you how to convert a ready java file to a batch file on Windows so that we can run the finished java program without using a development environment (Eclipse, NetBeans).
Let's just imagine a program. It should be a program that should contain at least one graphic object.
The program can contain any functions. We have selected from our past posts a simple program in which the user can log in to any computer. For example, it can also serve as a security barrier for a program. The use is arbitrary.
In our case, the program knows only one user. The user is called "Java2Enterprise" with the user password "Java2Enterprise". If the user types in the correct username and password, the login is confirmed. If the login is faulty three times, the program will report an error.
Let us now turn to the main goal of this post, namely to create a batch file. A batch file is nothing more than a program that only works on Windows as such. This batch file calls with a specific command the file in which the Java program has been saved as a .jar file.
So it's not a complete program so we can say it will work on all windows machines. We need to redesign the batch file on every machine in which we want to run the Java program. But this is very easy as thought. We can create this kind of call of a finished file also under Unix for it but in the future on another post office.
Step by step, we will take steps from you to a finished Java program on a batch file.
Step 1:

As we can see in the picture, the program is in the final stage and can therefore be converted to a batch file.

Step 2:


To be able to execute the program with a batch file, we first have to transform it to an executable (.jar) file.

Step 3:

Step 4:

We have to pay attention to where the program should be stored so that we can find it later. After this has been done, we will click on the Done and Save the executable file as in the picture.

Step 5:

In our case we saved the program named "LogInGUI" on the desktop.

Step 6:

Now let's start with a very simple text document.

Step 7:


Step 8:


After we have created the text document, we need to determine the file path of the executable Java file. In the properties we copy the file path of the .jar file in between memory and close the window.

Step 9:

Then we open the file that we have created as a text document and type in the command as in the picture on this text document.

Step 10:

Here we have to be careful. If we want to save the file, we have to change the file type to "All files" so that the saving process with the extension .bat can be recognized as a batch file. Once this has been done, we can choose the name of the batch file, which is Any and this Save.
Step 11:

Now the finished batch file is on the desktop and ready for use.

Step 12:

Finished.

We hope that with this tutorial we could show you how to transform a finished project to a file in which one can neglect the use of a user environment.
For questions or tips we are at your disposal.

Kommentare

Beliebte Posts aus diesem Blog

Ein Kleines Spiel mit Altersabfrage

Zufallszahlen und Verzweigungen in Python