This question already has answers here:
Use of the MANIFEST.MF file in Java
(2 answers)
Closed 6 years ago.
I have a basic question about the manifest file: when is this file created?
Is it created in the .class file when we compile a java file? Or should we create the manifest file from the command line after the .class file is created?
Update: you can find the answer here: Use of the MANIFEST.MF file in Java
The manifest file has nothing to do with the compilation/running process of a class.
If you configured your project correctly in your IDE (depending on the IDE), it will be generated during the build project process.
If you are working using the command prompt and notepad, you can always create it manually.
Related
This question already has answers here:
Where does IntelliJ put .class files when it compiles during typing
(5 answers)
Closed 2 years ago.
Does the IntelliJ IDEA provide access to compiled “.class” files or decompiled “.class” files? I’m enrolled in a course that requests for students to submit compiled “.class” files.
IntelliJ does not produce any .class until you make your project
Image showing how to make your project
After making your project the class files will be in Target folder:
Image showing the class folder
This question already has answers here:
How can an app use files inside the JAR for read and write?
(5 answers)
Closed 6 years ago.
I am successfully able to read and write to a file in eclipse. I am also able to read from a file in the jar. However, I am not able to write to the file in the jar. It is located in a class folder called res. I have also unzipped the jar file and it contains the file I need to write to but it is not modified after the first run.
How can I do this?
I have tried BufferedWriter and PrintWriter but no effect. I tried usingFileOutputStream but I cannot construct it using getClass().getResourceAsStream(path) as it returns an InputStream.
Jar is an archive, you are not supposed to write into the file of a jar.
You write to a file outside and create a jar later.
This question already has answers here:
Compiling a java program into an executable [duplicate]
(7 answers)
Closed 7 years ago.
In C/C++, the .exe file is automatically generated by the compiler when we run the code.
My question is how do you generate the .exe file in Java instead of just hitting run every time when we open up the .java file.
To do that, you'd need to create an Executable .jar file. Here's the instructions on how to do it.
This question already has answers here:
How do I create an .exe for a Java program? [duplicate]
(7 answers)
Closed 9 years ago.
I have created a project in java Netbeans and I want to create an .exe or .jar file that can be run on any other systems.
my project have a Main.java class and an other class GetRules.java .
the .exe file should be such that it can be run in any folder that contain train.txt as input and create Model.txt as output
how can I do this?
what you are looking for is an executable file which can execute you project
calling you main class
so here is what you can do
step 1 : collect all the files , class files
step 2 : create a jar file collecting all the files from your project
step 3 : this.jar file is executable on any environment with a JVM available
you will have .jar file , rather than .exe file , but serves you the purpose
you can refer this link to learn how to create jar files
Java programs are not compiled into exe files but Java byte code which is usually stored in jar containers. exe files run on Windows systems only, but Java byte code is platform independent.
What you could do is use a wrapper like Launch4j. It wraps the jar file into an exe file.
This question already has answers here:
How do I create a ZIP file in Java?
(2 answers)
Closed 9 years ago.
Is it possible to compile class file to jar file not using jar -cvf options.
I want to compile jar files by source code.
Cant somebody show me some example codes
A JAR simply is a ZIP file.
While I am not quite what you are trying to achieve, I can give you these hints:
Compiling: javac Hello.java
Creating a JAR: zip Hello.jar Hello.class
If you want to have a JAR containing your sources, you could as well run the above command with: zip Hello.jar Hello.java
Also note that, if you are using a build tool like for example maven, there are various plugins for suchs tasks such as 'assembly' (for maven).