Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to make a jar file for stand alone java application

 
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
Posts: 12893
63
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: 70305
283
  • 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.
 
Screaming fools! It's nothing more than a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic