Can’t execute jar- file: “no main manifest attribute”

I have installed an application, when I try to run it (it’s an executable jar) nothing happens. When I run it from the commandline with: java -jar “app.jar” I get the following message: no main manifest attribute, in “app.jar” Normally, if I had created the program myself, I would have added a main class attribute … Read more

What is “String args[]”? parameter in main method Java

In Java args contains the supplied command-line arguments as an array of String objects. In other words, if you run your program as java MyProgram one two then args will contain [“one”, “two”]. If you wanted to output the contents of args, you can just loop through them like this… public class ArgumentExample { public static void main(String[] args) { for(int i = 0; i < args.length; … Read more

What does if __name__ == “__main__”: do?

What does this do? [python]if __name__ == "__main__": print("Hello world!") [/python]   40   Short It’s boilerplate code that protects users from accidentally invoking the script when they didn’t intend to. Here are some common problems when the guard is omitted from a script: If you import the guardless script in another script (e.g. import … Read more

Exception in thread “main” java.lang.ArithmeticException: / by zero

I have two questions about Exceptions. Firstly, I got this message from my code… Exception in thread “main” java.lang.ArithmeticException: / by zero This error message means dividing by zero, such as by doing int a = 5 / 0; A method can throw an Exception class instance, can’t it? But this is an expression. Why … Read more