simnciou
simnciou

Reputation: 7

How to call jar class

How to call JAR CLASS with CMD

I am a newcomer to java.

This is my JAR file

https://drive.google.com/file/d/16bL0n4KS9IP75tDJhhbeNLeiS3boX3iP/view?usp=sharing

I want to use CMD to call the CLASS inside JAR.

I tried to call getHardware()

java -cp uhfrcom13_v1.9.jar com.handheld.uhfr.UHFRManager.getHardware

I got the error

The main method is not found, define the main method as: public static void main(String[] args) Otherwise the JavaFX application class must extend javafx. The application class must extend javafx.application.Application

Please master teach me how to call

Upvotes: 0

Views: 131

Answers (2)

Menilik Belay Woldeyes
Menilik Belay Woldeyes

Reputation: 369

Make the following changes and it will work.

  1. Make sure to have a main method (public static void main (String [] args)) in your class where getHardware is a method, then call your getHardware method to work on from the main method [you should call the class from CMD and not the specific method!!].
  2. Make sure to use the following command, in CMD, assuming your class is UHFRManager and getHardware is a method inside it,
    java -cp "uhfrcom13_v1.9.jar" com.handheld.uhfr.UHFRManager
    I hope it works.

Upvotes: 0

Toma
Toma

Reputation: 390

In UHFRManager class you have to add public static void main(String[] args) - in this method you can call your getHardware() method. When running jar file, java is always looking for main method in your class.

Upvotes: 0

Related Questions