i tried to make a executable jar file.a program as follows

import java.io.*;
class studentmarks
{
String name;
double engmarks,phymarks,chemmarks;
double tot,avg;
public studentmarks(String s,double p,double e,double c)
{
name=s;
engmarks=e;
phymarks=p;
chemmarks=c;
}
void compute()
{
tot=engmarks+phymarks+chemmarks;
avg=tot/3;
}
void display()
{
System.out.println("nameis:"+name);
System.out.println("totalis:"+tot);
}
}

i saved it as marks.java file
then i compiled it into a class using command prompt
then i made a manifest file using command prompt main:marks
then i made a executable jar file using command prompt as follows
C:\mywork> jar cvfm marks.jar manifest.txt *.class
when i click on the jar file it does not open.i know something has terribly gone wrong
please can someone help me.i am just a begginer.
please.please
thank you

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

You have no main() method defined. You cannot run a class that does not contain a main method.

exactly you caught my fault.in netbeans there was the same problem.can you please tell how to define it.please

You have to write it. A class needs a main() method if it's to be invoked externally

public static void main(String[] args){
...
}

You have to write it. A class needs a main() method if it's to be invoked externally

public static void main(String[] args){
...
}

public static void main(String[] args){
tot=engmarks+phymarks+chemmarks;
avg=tot/3;
}
main method means main function can i define it like this.
like i have to functions one is to compute and other is to display

I would assume that you would use your "studentmarks" class in your main method, but that's entirely up to you. I assume you have some assignment.

I just told you why it was not running.

I would assume that you would use your "studentmarks" class in your main method, but that's entirely up to you. I assume you have some assignment.

I just told you why it was not running.

thanks for your valuable time but can you just please rewrite the program.i have no assignment just for information sake.please

import java.io.*;
class studentmarks
{
String name;
double engmarks,phymarks,chemmarks;
double tot,avg;
public studentmarks(String s,double p,double e,double c)
{
name=s;
engmarks=e;
phymarks=p;
chemmarks=c;
}
public static void main(String[] args)
{tot=engmarks+phymarks+chemmarks;
avg=tot/3;
System.out.println("nameis:"+name);
System.out.println("totalis:"+tot)}
}

would this be fine

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

Once you have your program working...
After to put it into the marks.jar file...
You would run it from the command prompt as;
java -jar marks.jar

This article has been dead for over six months. Start a new discussion instead.