-4

Is it possible to compile class file to jar file not using jar -cvf options.

I want to compile jar files by source code.

Cant somebody show me some example codes

1 Answers1

0

A JAR simply is a ZIP file.

While I am not quite what you are trying to achieve, I can give you these hints:

Compiling: javac Hello.java Creating a JAR: zip Hello.jar Hello.class

If you want to have a JAR containing your sources, you could as well run the above command with: zip Hello.jar Hello.java

Also note that, if you are using a build tool like for example maven, there are various plugins for suchs tasks such as 'assembly' (for maven).

rethab
  • 7,170
  • 29
  • 46