I am working on a Java project in Eclipse. In this I am using a third party JAR which I have put in on the classpath. Now I want to understand the code in the JAR file and want to see the actual code and navigate through the third party code just like my own code.
My question is this: Instead of me manually decompiling all of the class files in the JAR and putting them in the appropriate folder as per package declaration, is there some way in which Eclipse will decompile them for me, and put them in the appropriate folder? What should be the approach taken in such a scenario?
The decompiler I use is JAD. It has an eclipse plugin, Jadclipse.
You can download JAD from http://www.varaneckas.com/jad
You can get Jadclipse from http://sourceforge.net/projects/jadclipse/. Click on the download jar and then simply copy the jar into your Eclipse/plugins directory, and restart Eclipse. Set up the path to JAD from Preferences->Java->JADClipse. Then trying to view a class should give the decompiled code.
I have been using Java Decompiler for some time and have found it very useful, i don't know about eclipse but it seems to have a eclipse plugin: JD-Eclipse
Related
I open a newpro-01.jar package:
I can add it as a library, so I can see the code.
but now I want to modify the code, then export a updated jar package. how to do that?
Simply you can open it in any archive opener such as 7-zip.
If you want to change java code you need to de-compile it using jd-gui and do what your code changes and make jar again.
jd-gui download link
I'm trying to import jar file ( which is a plugin for jmeter-i would like to edit it and again i want to jar it in eclipse ) in eclipse to see the source code of it.But im not able to see the source code of the jar file.
Can anyone help me how can i decompile a jar and make it editable in eclipse.
i decompiled online and used it in eclipse but eclipse is throwing number of errors.
By using jd decompiler i can view the .class of it .but i would like to edit the jar file according to my requirements.
From comments you need Jmeter InfluxDB Plugin.
Download source code and uzip it.
Apply your fixes and use gradle to build the jar in Eclipse.
I've made a project in Java using Eclipse using the jnetpcap library which needs WinPCap to be installed to work properly. However, there's no winpcap library included in my project only jnetpcap. But when i extract the project into a generated jar with libraries, or with the libraries in a different folder, it somehow doesn't work. Why does everything work when i run the program from eclipse, but not as an extracted project?
Thanks in advance.
I faced the same issue few years back. Jnetpcap for eclipse comes with winpcap. You need to export your project on eclipse as runnable jar. There you have an option to select which says extract required libraries in the generated jar. In this way, the all the dependent libraries will be included in the exported runnable jar file.
The links below are some of the helpful links:
Create runnable jar in eclipse
Visit the post on winpcap website jnetpcap: a java wrapper for libpcap and winpcap
Does this thread helps you out? I would guess that you have not wrapped your dependency into the .jar file but only in eclipse. That is why it works inside your IDE.
You didn't declare your main class for the jar file.
Right click on your solution in eclipse->Run as-> Run configuration -> Main class -> choose you main class.
Now build your jar from the beginning and try to execute it.
I did some robot framework python examples with pybot, and referenced .py files as my library files. The folder structure I used was test/lib/myLib.py and test/test/myTest.robot, where /test was at the same level as the /src folder in my project in eclipse.
I then tried to do similar things with a java project using jython. I have /test/test/myTest.robot which imports the library ../lib/myLib.java. I even tried importing this file using RIDE, but it always shows up as red text, meaning the import failed. The specific message I get from using jybot on the command line is:
"Importing test library 'C:\Users\cody\git\myProject\test\lib\myLib.java' failed: ImportError: No module named myLib"
I read that I might need to add it to classpath, and I think in order to do so, I need to make it a .jar file. I'd rather not do all that if possible to just leave it as a .java file. I attempted to add the lib folder to the build path... By that I mean I added the /test/lib folder to the "Source folders on build path". I also exported the darn thing as a jar and added that as a library. All this was done from the project properties in Eclipse.
I'm pretty stuck... any ideas how to get this working?
Java being a compiled language, you need to compile your java Class before importing it with RobotFramework.
Normally, Eclipse would do that for you, and put the resulting .class files inside a bin repository. If not, you can issue the javac path/to/file.java command, and move the resulting .class file where you want it (somewhere referenced by the classpath.
From within the .robot file, you should have the line Library test/lib/myLib, without neither .java nor .class at the end.
I'm developping my first Java application which actually needs a 3rd party package and now I'm lost as to how to actually use it. The packages I need are from VLCJ so that I can embed a media player in my GUI.
Usually, I can just import packages and classes, but is this possible with 3rd party packages? They have a .jar file to download at their website, are the packages stored in that? And if so, how do I go about using them in my own application?
You just need the third party JAR to be on your project's classpath. What IDE are you using? In Eclipse you would do:
Go to Package Explorer window on the
left. Select the Java project you are
working on and right click. Click
Properties. Then click Java Build
Path. Click Add External Jars.
Or you could modify your system wide CLASSPATH to include the JAR. Or you can do it on the command line e.g.
java -classpath C:\java\thirdpartjars\thirdparty.jar MyProgram
(you can use the argument with javac too).
There are many ways to crack this nut.
Yes, the JAR file you download is an archive (basically a .zip file) of compiled .class files which you can then import into your own application.
The only thing is you need to add the .jar file to your application's classpath for you to use it before you can import it.
I would suggest looking at a good Java book or tutorial (for example, the official Java tutorial) as this is all stuff that should be covered.
You need to add the jar file to the search path of javac when you compile your project; and you need to make the jar available at runtime-- it needs to be in the classpath of the java process that runs your program.
If you are using an IDE, you usually update these paths in the project settings.