Run jar file in command prompt [duplicate] Ask Question. Asked 10 years, 8 months ago. Active 1 year, 11 months ago. Viewed k times. Improve this question. Community Bot 1 1 1 silver badge. Nirav Nirav 5, 4 4 gold badges 33 33 silver badges 44 44 bronze badges.
Add a comment. Active Oldest Votes. Improve this answer. Bala R Bala R k 22 22 gold badges silver badges bronze badges. More times when you usea a '. Thanks : — user Using these command you can run the jar file using the background process.
Use this command if you dont have a manifest or to run a different main class than the one specified in the manifest: java -cp foo. That's the step you missed that caused the JVM to not be able to find your Generator. DaoLam - The argument after -cp is the classpath. It is a list of directories separated by ; characters. The first item is.
The second item is.. Duffymo is telling you that you need to include the current directory the location of Generator. The fact that I'm here shows that I'm not a pro at Java yet and I'm still learning. After reading jahroy's comment, I realized what it means and I already know it from before.
My brain was probably just dead at the time I posted that comment. Thanks though. It works but there's something I don't understand. After reading other posts before you posted yours , I added the current directory to the classpath which is supposed to be the same as ".
Why is that? Show 2 more comments. You should run the program including again the same cp: java -cp "lib directory where i put all the jars" MainClassOfYourApplication After you compiled it with: javac -cp "lib directory where i put all the jars" AvroReader. Razvan Razvan 9, 5 5 gold badges 36 36 silver badges 49 49 bronze badges. You can't just use a directory of jars; you'd need a wildcard.
A directory classpath entry is only for class files, AFAIK--a pointer to docs stating otherwise would be helpful. I'm looking at the 1. I'm calling a method from AvroReader in another class.
This is how I ran it: javac -cp "jar directory" AvroReader. Dave Newton: Yea I actually have a wildcard. It's basically something like ".. DaoLam - If you're just calling java Generator it won't work because you're not specifying a classpath. Thanks and happy coding! We hope you enjoyed this article. If you have any questions or comments, feel free to reach out to jacob initialcommit.
Recommended product: Coding Essentials Guidebook for Developers. Subscribe to be notified when we release new content and features! Follow Us. Follow us on your favorite channels! Recommended Product. Coding Essentials Guidebook for Developers.
0コメント