0

I just have some (134) .java source files with me and I'm pretty sure that contains all the necessary code! I want some quick tutorial to compile this program into a .jar file. (I'm on a windows platform btw)

I have tried javac and jar commands. I got my .jar file but it's not opening!!!

Thanks in advance!

Ragav Ssr
  • 31
  • 1
  • 1
  • 8

3 Answers3

1
  1. Place all the files you want to include in the JAR file inside a single folder.

  2. Open the command prompt in Admin Mode

  3. Navigate to the folder where you stored your files.

  4. Set the path to the directory of the JDK bin. You will need to run the jar.exe utility to create a JAR file, and that file is located in the bin directory.

Create the JAR file.

The format of the command line for creating the JAR file looks like this: jar cf 'jar-file'.jar input-file(s)

K.Suthagar
  • 2,226
  • 1
  • 16
  • 28
-1

Best practice is to make use of Ant/Maven/Gradle kind of build program tools that can take care of creating Jar files.
Other way is to just make use of Eclipse's feature for exporting the project as a light weight Jar file or Runnable Jar file(which includes dependencies).

enter image description here

A.K.Desai
  • 1,274
  • 1
  • 10
  • 16
-1

You can use WINRAR. right click on file (put inside all your .java files) and compile by using winrar; choose format .zip (important) and save filename.jar (important)

Abdulin
  • 7
  • 6