Run java class with jar files
Collectives on Stack Overflow. Learn more. How to run a. Ask Question. Asked 8 years, 6 months ago. Active 6 years, 8 months ago. Viewed 16k times. What I'm basically trying to do here, is run a. I tried to do: Runtime. Andrew Thompson k 40 40 gold badges silver badges bronze badges. A few tips. Read and implement all the recommendations of When Runtime. That might solve the problem. If not, it should provide more information as to the reason it failed.
Then ignore that it refers to exec and build the Process using a ProcessBuilder. Also break a String arg into String[] args to account for arguments which themselves contain spaces. AndrewThompson This seems like an answer to me instead of just a comment. ViktorSeifert If the question had not already been offered a correct answer I might have submitted it as one.
Of course, it might become the answer to the next few questions posted by the OP. Add a comment. Active Oldest Votes. Simple jar file that does not contain a manifest file so you simply run your main class by giving its path java -cp. Assuming you are in the directory where myJar. A fully qualified path is preferred here as well. This is the right way to execute a. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Collectives on Stack Overflow. Learn more. Run class in Jar file Ask Question. Asked 10 years, 5 months ago.
Active 3 years, 2 months ago. Viewed k times. What do you mean when you say that you want 'to use' that class? Is there a main method that you want to call in particular? Add a comment. Active Oldest Votes.
Use java -cp myjar. If the class is not in a package then simply java -cp myjar. If you are not within the directory where myJavaJar. Here, flag cp is to set the jar in the java class-path. I want to be able to run each one of those as per the need.
I am trying to run it from command-line on Linux box. But is there any way by which I can specify some argument on command line to run whichever class I wish to run? I tried this: jar cfe myJavaJar. Solution: The solution for this issue is described below. You can create your jar without Main-Class in its Manifest file.
0コメント