Can .java file be saved as .class file without compilation? - jar

I am having a jar file from my project. I need to make certain modifications in a particular class. So , I extracted the particular class file , decompiled it and converted it to .java file. I made my changes by editing the .java file through notepad++ and then I saved the file as .class file and added it back to the jar. will it work?

It won't work.
You must have to compile this & add .class file. To compile it successfully you have to add all dependencies.

Related

Compile a folder with java classes into a JAR

I had a jar file paymentService.jar which had a lot of class files. I have decompiled a class file, made some changes to it's code and created a .java file. I have kept the .java file in the same location as .class file.
How can I recompile the .java file and then recreate a JAR of the folder.
I can't compile the .java file using javac /my/../example.java because imports will fail.

PhpStorm compile Less folder to style.css

I have a folder with Less files, split in parts to have a cleaner workspace. But I want them to be compiled by PhpStorm to 1 file (styles.css in a css folder). I installed lessc and it compiles the files separate. See picture 1
As I said I would like to have all files combined into css/styles.css But I don't get this configured right. My configuration is as followed:
I hope someone can explain what arguments I could use.
When Track only root files option is enabled in Less file watcher settings, file watcher produces a single .css file with name matching your "main" .less file (the one that imports all your "partials") that includes the merged content of all your .less files. No individual .css files for partials are created

How to update a JAR file with a modfied Java file

I have one JAR named as abc.jar with 15 class files. In JAR file I need to modify xyz.class, so I decompiled to xyz.java and modified it.
How can I update that JAR with the modified Java file? While trying to create (compile) the JAR file I am getting errors.
You can add your newly compiled class to the jar and overwrite the old one, here is how to add xyz.class and xyz.java to the jar :
jar uf abc.jar xyz.class xyz.java
See here for more about updating a jar file.
Or simply you can use any archiving tool, like winrar to open and add files to the jar.
Compile the xyz.java and replace the xyz.class file directly in jar without building the jar again, if the single class has been modified.

Jar file which contains the Javadoc?

Is it possible to create a jar file which contains the javadoc ?
For now, I'm creating a jar file & javadoc folder.
1. I want to create a jar file that contains the javadoc , can I ?
2. Can I do so without attaching the source code into the jar file ? (just the jar with javadoc) ?
Thanks
The short answer is yes. A jar file is just a zip with a manifest and additional features. You can put any type of file in it, including images, html files etc... All you have to do is jar your javadoc folder exactly as you would do for a classes folder.

How do you include .java files and .html files in a .jar file when you take Clean and Build in Netbeans 7?

If you have files in the build/classes/folderToJar Netbeans7 takes the .class files and make a .jar file when you take Clean and Build.
But how can you have .java files and .html files go into the .jarfile as well?
First Create a package(Say html) under Source Packages
copy all of your html files to this package(when you create a package,a folder in the name of your package will be created inside your project src folder, so copy files to it)
You can access your html file from your program as
URL someURL = yourclass.class.getResource("/html/yourhtml.html");

Resources