• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to make a jar file for stand alone java application  RSS feed

 
Greenhorn
Posts: 25
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written a simple java class which has a main method.

package org.rohit.useUtilities;

import com.rohit.utilities;

public class TestJars
{
public static void main(String[] args)
{

float d = Divide.divide(9/2);
float m = Multiply.multiply(2*24);
float a = Add.add(5+2);
float s = Subtract.subtract(9-2);


System.out.println(d+" "+m+" "+a+" "+s);
}
}

I have written 4 classes in com.rohit.utilities package namely Divide,Multiply,Add and Subtract.
Below is the code for the Add class

package com.rohit.utilities;

public class Add
{
public static float add(float a, float b){

float ans = a+b;

return ans;
}
}

I am able to run the TestJars class.

Then i made a jar file of the 4 classes(utilities.jar) and provided -cp option in the java and javac commands to run TestJars class. I was able to do it.

Now i want to make a jar file for the whole application.

So, i made a jar file as -> jar -cvf myJavaApplication.jar org com

But when i run the jar file as --> java -jar myJavaApplication.jar

I get the following error,

no main manifest attribute in myJavaApplication.jar


Any help would be gladly appreciated.
 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please learn to use code tags. See how much easier it is to read when you do?


 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Tutorials. That's got what you want. There is a section about jars in that link, and that has a section about setting the entry point. It all has to do with editing the manifest file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!