0

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 by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by hfx642
Featured Replies
  • 1
    Ezzaral 2,714   5 Years Ago

    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. Read More

0

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

0

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

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

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

1

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.

0

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 by Ezzaral: Added code tags. Please use them to format any code that you post.

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.