Commander300
Commander300

Reputation: 13

How to launch program in psvm?

How to launch a program in psvm with one command? How does the application know which class to launch first?

I know that psvm should only have starting command and nothing more.

Could you explain this to me?

I mean how to create proper public static void main(String[] args) in a simple program on Maven. Should I create a class i.e. Starter with method run (with sequence actions) and in psvm write new Starter().run()?

Upvotes: 1

Views: 6690

Answers (3)

GIIRRII
GIIRRII

Reputation: 88

Considering your comments you want to do something like this :

public class Starter{
  public static void main(String args) {
    new Starter().run();
  }
  public void run() {
    //your logic
  }
}

once you write this, you have multiple options to run this I am mentioning a few

1) by building jar and then executing that jar using java -jar command

2) or by executing maven command once you have compiled your program using mvn compile, mvn exec:java -Dexec.mainClass="complete name of your main class i.e including package name."

a few links http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Maven_SE/Maven.html

hope this might help

Upvotes: 1

Arvind Kumar Avinash
Arvind Kumar Avinash

Reputation: 79355

psvm stands for public static void main as shown below:

public static void main(String[] args) {
   // Your code here
}

psvm is not a standard Java terminology. You can call it as a Java slang. It is the entry point in your standalone Java application i.e. when you run an executable jar, it will execute the class having psvm. There are so much of content about it on the internet e.g. https://dzone.com/articles/executable-java-applications

Upvotes: 3

parthi
parthi

Reputation: 101

The main() is the first entry point of Java application. Java Virtual Machine is told to run an application by specifying its class using the application launcher & it will look for the main() with exact syntax of public static void main(String[]).

Upvotes: 1

Related Questions