I downloaded the eclipse from the google bundle but yet I dont know if it is optimizing the code once it gets compiled. How do I enable optimiziation and obfuscation for my code in eclipse for java or do I need to get a special plugin to do so? I want to make my files as small as they can to be a quicker download for users
If this is a bad question please do not -rep me, just tell me and I'll remove it
I've used ProGuard once or twice, never extensively but my understanding is this: it is an external bundle of files that you must run (either command line or through its GUI) in order to use it. I have used the GUI and it gives you several different tabs for each of the options (Optimizing, Shrinking, and Obfuscation). You can find their project page here with more information and detail on how to use it. As far as I know there is no IDE intergration for ProGuard.
Related
This is my first StackOverflow question, and I'm also a Grade 12 student, so apologies if it is a stupid one - feel free to let me know if it is, however, after numerous hours searching the internet, I can't find an answer to this.
this is not homework help.
Background
I am currently writing a program in Netbeans that will deal with large COVID datasets, and I'm looking to use some external libraries to make operations easier. The ones I've looked at are
https://github.com/jtablesaw/tablesaw and https://github.com/nRo/DataFrame.
However, I have only ever used "Java with Ant", and both of these GitHub's only mention using the library through Maven dependencies in the pom.xml file. I have never used Maven, and I am very unfamiliar with Build Tools in general. As when I was introduced to Java, my teacher instructed me to use Java with Ant. That being the case, any time I have used an external library before I have simply added the .jar files into my library folder and used
import foo.bar; or import foo.*; to use the libraries.
My question
Is there a way for me to use either of these libraries without switching build tools? For example, download the source and make the .jar's in a way that isn't overly tedious, so that I can use the libraries the same way I am used to? Or, perhaps something I'm missing that allows me to download them in that format? If not, seeing as almost every Github library I find instructs me to use it through Maven dependency, should I stop using Java with Ant altogether and start learning how to write programs using Maven?
Any insight is greatly appreciated. If this has already been answered, feel free to link the answer and sorry for cluttering up the forum. Thanks.
From one of the Maven websites you can download the libraries and use them as normal. First find the artifact page, for example using mvnrepository.com as shown below, or you could use the https://search.maven.org/:
Find the relevant page by searching for the artifact, then once there you can choose the version:
Then click on "View all" to see the artifact jar files:
Then lastly right-click the file you need and choose save:
I am trying to write a standalone Java application in IntelliJ using edu.stanford.nlp.trees.GrammaticalStructure. Therefore, I have imported the module:
import edu.stanford.nlp.trees.GrammaticalStructure;
Currently, Intellij doesn't recognize this and many others of the imported external libraries (cannot resolve the symbols) and is also not able to automatically download/import them.
Is there a way to use the GrammaticalStructure class without having to download the entire Stanford CoreNLP .jar and adding it to the project as a library? This question applies to other dependencies as well, since I want to use other external libraries but avoid including their .jar files as much as possible (to minimize the size of the final application, given that it will be standalone). Unfortunately, all the solutions I have found proposed exactly that.
Apologies if I have overlooked some basic setting or setup steps, it has been a while since I have worked with Java.
Any help is greatly appreciated.
If you want to use it means you want to execute the code in them. How is the runtime supposed to execute code that is does not have? How is the compiler supposed to know how the code is defined (e.g. what the classes look like)? This is simply impossible. If you want to use the code you have to provide it to the compiler as well as the runtime.
If you just dont want to include all of that code into your application, you need either access to the sources and just pick the class you need or you need some kind of JAR minimizer as #CrazyCoder suggested.
I am trying to take files from a jar that is part of a working project, and put them back in to the project so I can run it while making subtle changes to the classes.
I have read it is possible to extract a jar, decompile, edit, reassemble the jar and run the project, but I dont want to do all that every time I make a small edit.
I have tried extracting and decompiling the jar, and then creating a new package in eclipse with the same name as the original jar, and then adding all the files back in; however I get hundreds of errors.
I am very new to java and I realize this is beyond my current skill level, so any help is greatly appreciated if there is a simple way to do this. None of the other threads on this give a clear answer.
Compilation and decompilation are lossy processes, so in general, you can't expect to be able to re-compile decompiled code. If you want to make changes to an application and run the modified version, your best best is disassemble it with Krakatau, edit the assembly file, and reassemble. The Krakatau assembly format is designed to be very close to the classfile format, so you can make changes without disrupting everything. The downside is that you have to understand Java bytecode.
I'd also suggest checking out Konloch's Bytecode Viewer or Samczsun's Helios, which might be able to do what you want.
In my Android application, I am using lot of open source JAVA libraries as source. It makes the application very huge in size.
Number of classes coming around 6000+. I want to remove the unused classes from it. Any one have idea about how to do it. I find many tools, but that is for removing unused codes. Thanks in advance.
Use Proguard. It strips away unused classes and libraries. Link: http://developer.android.com/tools/help/proguard.html
EDIT:
The gc overhead limit exceeded is not because you are using proguard. Its because the memory allowed for eclipse to use is low. You can fix this by increasing the memory limit allowed (https://www.simplified.guide/eclipse/fix-gc-overhead-limit-exceeded). Do this, run proguard, and your app size will be minimal.
Well if you are using open source java libraries you should first find out what licences those libraries are distributed under. Some licences do not allow you to repackage distributables other licences will only allow you to repackage if you make the new software open source (that includes your code). http://opensource.org/licenses
So after you have checked the liceneces and or contacted the rights holders.
You could write a tool that follows the dependency tree from your classes through all of your third party code and produces a list of classes that are not in that tree. I imagine most IDE's are not going to do what you want because they will consider a library as either used or not.
proguard does this for java.
From what I'm seeing it's already part of the android stack - http://developer.android.com/tools/help/proguard.html .
Look at the link and try to find out why it isn't working for you (probably you aren't creating a Release build).
If it is working, and you still have a huge file, then you are probably using libraries that use a lot of files, and there's not much you can do about it.
Step 1
Generate usage.txt and mapping.txt with Proguard or R8
Add -printusage to your proguard.pro file Run
./gradlew app:minifyReleaseWithProguard or ./gradlew app:minifyReleaseWithR8
Step 2
Find class name records that is in usage.txt but not in mapping.txt, those are the unused classes that are removed by Proguard/ R8
It's not hard to write such algorithm but you can consider my approach using Java Set data structure
More details here
6000 classes ????? Well this is why people pay like 2000 for a compiler that removes unused code. If you put your code in eclipse it will place a yellow line under libraries, and variables that you are not using at all.
Hope this helps.
I have a limited selection of original source code overlayed onto decompiled code in a sources jar.
This is great as it gives me easy ability to drill down into the code when debugging however it seems to have a side effect of disabling the javadoc from the associated javadoc.jar from working in eclipse despite me having a separate javadoc.jar file with the javadoc in it.
I assume this happening because eclipse is finding the 'source code' and assumes that all the javadoc is in the source and therefore there is no need to check the javadoc.jar file.
I'd like to be able to tell eclipse (preferably using maven) to not use the sources.jar for javadoc and only use the javadoc.jar. I would still like to use the sources.jar for source code.
I have assumed that eclipse is preferring to display javadoc from sources and may be wrong so please correct me if that is the case.
Also, I may just be doing something simple the wrong way so please let me know if that is the case.
I am hunting for the same thing. I have some source jars I created with jad (and since they are decompiled, they have no JavaDoc in them) and attached as source attachments. I also have the JavaDoc attached. It seems like it is a limitation of Eclipse. It will scrape the JavaDoc from the sources and display it (even if its empty) rather than looking to the JavaDoc. I wish it would notice that the JavaDoc was missing from the source and try the JavaDoc location instead. If I don't find a solution, I'm going to post the question and/or feature request over at the Eclipse site.
One workaround might be to integrate into the java decompiler (like jad) the ability to examine both the source an the javadoc, and put the javadoc back into the source. It would also then have parameter names for methods available too so it could put those back in. Lots of people have suggested this, but I cannot find anyone who has done it.
A couple of caveats. First, jad hasn't been maintained in a long time. The JD-Core/JD-Eclips website has vanished. And I have not found a better Java decompiler than jad. What happened to all the great Java decompiling gurus and solutions? Second, it might be tricky with the "align for debugging" feature to make sure the JavaDoc comments don't take up more room than is available.