I need to add some Unicode character to JAR file, therefore I decompile the JAR file with JAVA DECOMPILER and after that I was be able to add Unicode character with Eclipse. So I need to create JAR file again after modification. I export JAR file from project and everything seems ok. But I have some problem. When I opened the original file with Java decompiler (before modification) everything is .class, after modification and export JAR with eclipse everything is .java, how can I export JAR file with eclipse as original file with .class instead .java?
before decompile and modification
after decompile and modification with eclipse
both file is jar before and after modification.
Thanks in advance
try this way
File menu --> Export --> select JAR file --> select the resources folder --> finish
for reference enter link description here
Related
I'm using VSCode for my IDE for Java. I have the Setting.json file configured to output my .class files to a directory called 'build':
"java.project.outputPath": "build"
My Project Folder/File Layout is as follows:
math
\src
Main.java
\lib
Math.java
\build <- This is where I want my .class files to be built keeping the same file structure as
in the src folder.
When I use
javac src\Main.java
The compiler writes the .class files in the .\src directory, but I'm telling it to write the output in the .\build directory. Any ideas what's going on?
I didn't see settings.json in the workspace directory structure you provided. I think this may be the cause of the problem.
"java.project.outputPath"
This setting only takes effect in the workspace scope.
You can create a folder named .vscode in your workspace, then create settings.json:
Add the codes in workspace settings.json: "java.project.outputPath": "build".
I fixed the problem. I was using the Command Line. VSCode only builds to the specified build path if the build command is run through the gui.
I'am working on a python script , which involves few steps of creating a jar file.
However when i run the following lines of code i get the jar file created, having .java files and not .class files .
subprocess.call(['jar', 'cvf', 'process.jar','C:/my data/temp/process/src'])
Is there any way to get the jar file created with .class files similar to Export generated class files and resources checkbox in export jar dialog in eclipse .
Thanks
Make sure where is your *.class files located, I assume it is in bin directory or something:
subprocess.call(['jar', 'cvf', 'process.jar','C:/my data/temp/process/bin'])
Is it possible to take existing .class files and a MANIFEST.MF to create a jar file?
Is there a library that can create a "valid" jar-file? I tried it manually and it didn't work (using 7zip).
ERROR: "Invalid or corrupt jar file"
If everything has been compiled before, it should (in my understanding) theoretically work, if you create a new zip file, put all the files in it in the original structure and then rename it to "jar".
My idea is to program something like this with java code. A solution where I could add a file to an existing jar, would also be ok.
If you're interested in why I want to use this, look at my initial question: Compile javacode out of a running java accpilaction - on a system that hasn't JDK installed
Well Jar -cf
Try the jar command in $JAVA_HOME/bin
$JAVA_HOME is the path to you JRE/JDK installation
I am trying to build the project Sharpen by versant. I will start out that I don't know anything really about java and it's tools, hence why I am trying to build Sharpen(Java to C# converter). So I ended up building the project, but now I am left with a bunch of .class files in the bin directories.
How can I turn those .class files into a executable .jar file so I can run it? Sharpen is an eclipse plug in, so will I need to do anything extra, and will I have to manually remove files from their subdirectories in the bin folder and add them to the main bin directory?
Go to file->export->JAR file,
select "Export generated class files and sources" and make sure that your project is selected, and all folder
I have a Java desktop app with gui.My app is using some xml files from the "export" folder. When I export the app into a runnable jar file, the app is not working properly, because the jar does not contain this xml files, or the path to the files is wrong.
Is there any possibility to export a Java app into an executable jar file from eclipse and to tell somehow to include an additional folder, with the same structure?
More information
My project is using some xml files, organized in the following hierarchy:
templates -> HASH CODE fgrtsgdtagsdnjf -> test -> document.xml
templates -> HASH CODE sgdtfhfnjnjcnjc -> test -> document.xml
When I export my project into an executable jar file I don't know how to specify to my app to use that files. I have FileNotFoundException.
So far, I succeed during export into an executable jar file to export that folders with XML files as well. So the files exists in the jar archive. but I do not how to indicate to use them in my project?
Since you said you get FileNotFoundException, I assume you are trying to use File, FileStream, FileReader or similar; you can't use those, you need to use class.getResourceAsStream() (search first in the the same directory as the class) or class.getClassLoader().getResourceAsStream() or getSystemResourceAsStream().
Eclipse packages the contents of the source folders (i.e. src, export and test) in the root of the JAR, so if you have "export/document.xml" you'd use 'MyClass.class.getResourceAsStream("document.xml")'. And remember to close the stream.
My app is using some xml files from the "export" folder.
If export folder has only required xml files, then just move it inside src folder. It would be automatically included once you Export as Executable Jar
Another option is to right click the folder and select Build Path, experimenting with it might help.
Is there any possibility to export a java app into an executable jar file from eclipse and to tell somehow to include an additional folder, with the same structure?
When you export as executable jar there is an option to save scenario as Ant script. Later you can modify it and Run as -> Ant