0

I have got my files from my java programmer and have edited some .java files in netbeans and saved again.

How do i pack this into a JAR files that works? I am complete new into this java. All files is .java Think i needs to be .class, but how?

I tried to just put the java files into the JAR file like i do in ZIP and RAR's. But don't think this work properly. Can someone help me?

First of all, all my files is .java, i think it should be .class, but how can i convert them all to .class files?

Then i run:

  jar cf AvatarServer_Q.jar *

But need manifest, think it because of java to class.

JKMadsen
  • 127
  • 1
  • 1
  • 5
  • http://docs.oracle.com/javase/tutorial/deployment/jar/build.html. You can use IDE too in order to create a jar file. Simply, you should create an artifact and build them. –  Dec 26 '12 at 11:35
  • 3
    *"my java programmer"* Why not get your Java programmer to do it for you or teach you how it is done? This Q&A site is geared toward specific answers to specific questions, as opposed to tutoring. – Andrew Thompson Dec 26 '12 at 11:36
  • http://netbeans.org/kb/articles/javase-deploy.html#Exercise_1 – Rohit Jain Dec 26 '12 at 11:36

2 Answers2

0

did you read any tutorials? you can look at: create jar

to understand manifest file: manifest basics

vishal_aim
  • 7,636
  • 1
  • 20
  • 23
  • I have a folder with alot folders and java files. I have edited alot "files" and not only 1 in all folders, and want to execute all as JAR. So my question is; How? I have readed but cannot figure it out. – JKMadsen Dec 26 '12 at 11:46
  • show us your directory structure and the commands you've used to create jar by reading the provided links – vishal_aim Dec 26 '12 at 11:49
  • I tried "jar -cf AvatarClient.jar *" i am in the folder where all files is in folders etc. – JKMadsen Dec 26 '12 at 12:03
  • and what output do you get then? – vishal_aim Dec 26 '12 at 12:14
  • I get the jar, but when i try to run it i got Picked up _JAVA_OPTIONS: -Xmx512m Failed to load Main-Class manifest attribute from AvatarServerNEW.jar – JKMadsen Dec 26 '12 at 12:23
  • I think you need executable jar so that when you run it can find the main class file, for that you need to mention in your menifest file which is the main class like `Main-Class: DanceStudio` and create jar by mentioning new menifest file like e.g. `jar cvfm MyJarName.jar manifest.txt *.class` – vishal_aim Dec 26 '12 at 12:31
  • I have Meta-INF with ManiFest.MF in my folder in the jar. So cannot understand why? Can you please tell. But all my files is .java. How can i make them to .class? – JKMadsen Dec 26 '12 at 12:34
  • do you see `Main-Class` entry in that file? try including it by creating a new text file having that entry and creating jar with the mention of new manifest file (or you can just try to unzip and put that entry and zip again not sure though) – vishal_aim Dec 26 '12 at 12:37
  • Read the post again, i have modified it. It's because all my files in that folder is .java, i need to be .class. How can i convert it? Main-Class: server.AvatarServer is main class – JKMadsen Dec 26 '12 at 12:39
  • then you need to compile them to .class files first, get familiar with some IDE or javac command `javac -help` – vishal_aim Dec 26 '12 at 12:46
  • javac -cp -g * error: Class names, 'clothes,commands,database,gameInstances,items,levels,moods,network,robots,server', are only accepted if annotation processing is explicitly requested 1 error – JKMadsen Dec 26 '12 at 12:50
  • why are you going for `-g` option, please read some tutorial first (can be easily found) – vishal_aim Dec 26 '12 at 12:54
0

This is all you need: http://docs.oracle.com/javase/tutorial/deployment/jar/

How to make an executable jar file?

Community
  • 1
  • 1
Azodious
  • 13,752
  • 1
  • 36
  • 71
  • I have a folder with alot folders and java files. I have edited alot "files" and not only 1 in all folders, and want to execute all as JAR. So my question is; How? I have readed but cannot figure it out. – JKMadsen Dec 26 '12 at 11:45