• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to make a jar file for stand alone java application

 
Greenhorn
Posts: 25
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please learn to use code tags. See how much easier it is to read when you do?


 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic