“Error: Main method not found in class MyClass, please define the main method as…”

When you use the java command to run a Java application from the command line, e.g., java some.AppName arg1 arg2 … the command loads the class that you nominated and then looks for the entry point method called main. More specifically, it is looking for a method that is declared as follows: package some; public … Read more

Could not find or load main class with a Jar File

I got it working like this: TestClass.Java package classes; public class TestClass { public static void main(String[] args) { System.out.println(“Test”); } } Use javac on the command line to produce TestClass.class. Put TestClass.class in a folder classes/. MANIFEST.MF Manifest-Version: 1.0 Main-Class: classes.TestClass Then run jar cfm test.jar MANIFEST.MF classes/ Then run it as java -jar … Read more

Is main() overloaded in C++?

ยง3.6.1/2 (C++03) says An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main: int main() { /* … */ } int main(int argc, char* argv[]) … Read more

Multiple Main Functions

In Java, the computer determines the “entry point” when you actually execute the program, not when you compile. For example, from the command-line java MyClass searches for main() in MyClass. All other main() functions are ignored. If you are using an IDE, then you can set which class contains the main() function that you want … Read more

Using Spring 3 autowire in a standalone Java application

Spring works in standalone application. You are using the wrong way to create a spring bean. The correct way to do it like this: @Component public class Main { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(“META-INF/config.xml”); Main p = context.getBean(Main.class); p.start(args); } @Autowired private MyBean myBean; private void start(String[] args) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)