This question already has answers here:
How to run a NetBeans project in command prompt?
(9 answers)
Closed 6 years ago.
Im trying to run a javafx project file by using the cmd in another computer that does not have netbeans on it.
Any suggestion on how to run my project file without installing netbeans (the source file is rather complicated)
And what does a batch-file means?
With the jar file you can do either
java -jar path/to/jar/file
if the jar file has a manifest with a Main-Class entry, or
java -cp path/to/jar/file MainClass
where MainClass is the fully-qualified name of your Application subclass.
Related
This question already has answers here:
Can't execute jar- file: "no main manifest attribute"
(43 answers)
Closed 2 years ago.
In IntelliJ I created Maven run configuration, that looks like this:
When I run it, I get .jar file:
And when I run it, I get this message:
"C:\Program Files (x86)\Java\jdk1.8.0_251\bin\java.exe" -Dfile.encoding=windows-1250 -jar D:\Projekty\Programowanie\Portfolio\java-studying\MavenHelloWorld\target\MavenHelloWorld-1.0-SNAPSHOT.jar
no main manifest attribute, in D:\Projekty\Programowanie\Portfolio\java-studying\MavenHelloWorld\target\MavenHelloWorld-1.0-SNAPSHOT.jar
How do I run this .jar file from intelliJ?
You don't need to compile into a jar file, there's a terminal in IntelliJ to display println, just press the green start button in App.
In the future, follow these steps to create manifest and use Build>Build Artifacts>name.jar>Build to create a runnable jar file:
https://prnt.sc/txmlul
https://prnt.sc/txmp28
https://prnt.sc/txmsqa
This question already has answers here:
How to run a Java project in command line
(6 answers)
Closed 7 years ago.
I'm using a mac, and I'm trying to run a java project created in Eclipse from the command line. My project folder has a bin and src folder, each of which have folders game and display corresponding to packages. There are .java files in src/*/ and .class files in bin/*/
Here's what worked:
I compiled everything using javac src/*/*.java. I ran my project by going to the src folder (cd src) and using java game.Gomoku following the directions in this answer. Everything worked. The only problem was that now I had a bunch of .class files in my src folder, and I wanted them in my bin folder like Eclipse organized it.
The problem:
I figured out that I could do this with javac -d bin src/*/*.java. But then when I try java bin/game/Gomoku or java game/Gomoku or java -cp bin bin/game/Gomoku I get the error Error: Could not find or load main class bin.game.Gomoku. How can I run my project?
So while I was typing my question I came across a solution. After going to bin (cd bin) I could run my project with java game.Gomoku. I also found that my question had been previously answered here, but I'll post this anyways just in case my method for compiling (in my question) can help anyone.
This question already has answers here:
How to make a runnable jar file?
(4 answers)
Closed 7 years ago.
I'm trying to make runnable jar file of my java application. Each time I follow the steps of exporting application etc. It created a jar file for my application but when I run it, it shows popup 'java virtual machine. A java Exception has occurred'.
How can I resolve the issue?
This is correct, JAR IS a ZIP
JAR files are fundamental archive files, built on the ZIP file format and have the .jar file extension
Just run it!
This question already has answers here:
How to make an executable JAR file?
(5 answers)
Closed 9 years ago.
I have a directory in which I generated *.class files. How can I build executable jar file from this files.
What I need to know is
how to clean dir
how to put all files in jar and make it executable
Sorry people i didnt mentioned, i need do this programmatically in java code.
java cfe myJar.jar Classname.class myClass
and for exceution
java -jar Jarname.jar
Creating a Jar
If you're using an IDE such as Eclipse or Netbeans, there are specific easier ways to do it. If not I think the following command would work:
jar cfe <jar-file> <main-class-name> <class-files...>
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I convert my Java program to an .exe file?
I have Java project and will making a setup file to my project. İn my procet I have a jar file which runs my project. whan can I do to create a setup file to my Netbeans Java Project
There are software convert from jar to exe like JAR2EXE but it's not setup file
Check out Launch4J which will create an Windows executable from a Java JAR file.