i started to learn android program ,and i curious to see the code of the classes/
for example the class of import android.app.Activity.
how can i see the source code of the packages in eclipse?
You can attach source code to libraries. yourProject / Properties / Java Build Path / Libraries / yourLibrary / Source attachment, and then enter the folder or zip file containing the source code (which you need to download separately).
If you only have the object code (.class files), then you need to learn to read ByteCode (which Eclipse shows pretty nicely) or use a Java ByteCode disassembler.
As in android sdk what we get is a compiled jar file which contains all the classes.
So in eclipse you can't read the source, but you may use, The official online version to read the source code of classes:
http://developer.android.com/reference/packages.html
[In eclipse although by CTRL+Click on import may show you a bit about the class, although that won't be easy to understand :)]
Related
I decompiled a Java .jar file, after editing the problem i'm having with it, its not compiling again. So, i had to opt-in to using 7-zip to just bring out the class file and, now i've used 5 different Class Editors, all can't show me the codes like i can understand...
I used CE(Classeditor.sourceforege.net), dirtyjoe, javaeditor(javaeditor.org), Jad and JD-GUi(Seems not to do its work at all)
I imported the .jar file into Eclipse as a Project Reference Library and the most painful thing is i can see all of the class codes, but i can't edit it...It won't edit. But, it can run.
What can i do to Eclipse to be able to make it allow editing the .class files attached to it.
EDIT: I want A Class Editor That Shows in Codes Format, not bytecodes.
I have the source as well in .java format.
This Example is Eclipse Class Viewer(I want same, but not only viewer).
Eclipse Class Viewer Image, I want something similar
It sounds like you want to be able to edit class files directly. The Eclipse class viewer only works because it finds (in your project folder or online) a source code version of the jar that you're viewing. It's not actually looking at the class files and decompiling them, AFAIK. So, if you can view the source in Eclipse, your best bet may be to find the source version of the jar (on your machine or on maven, possibly, if you're using maven), and then edit it and build it yourself according to that project's build instructions. How hard that is depends on the library.
As far as being able to decompile, edit, and recompile, I'm not sure. I know that decompilers are not foolproof, and I've only used them as a last-ditch, read-only tool. It seems like it should work both ways, but I wouldn't be surprised to hear it doesn't.
There doesn't seem to be any code there. I expected to see class declarations so I could see what the code does but instead there's some
Are they somehow precompiled? What's the difference between included Jar file and a pure code?
You are looking at .class file, which is a generated when you compile .java file. To see what the program does, you have to look into .java file. You can refer official java documentation for that.
A .jar file is packaged file with .jar extension, it contains compiled java files and their class files. This file is usually imported into projects to use the classes defined in that package.
You can use "jar xf jar-file" command in command-prompt/terminal to extract the files from jar and look into the package.
A JAR will normally contain compiled class files. It may also contain source files or there may be a separate JAR that contains the source files, but not necessarily so.
If you want to use the library in your project, then a JAR of compiled class files is what you want. If you want the source code, then you'll have to see if it is available from wherever you downloaded this from. If all you want is to see how to use the classes, then probably what you want are JavaDocs for the library you are using. This is an HTML based API documentation.
Well, this is because you haven't attached any source for the mentioned dnsns.jar. You can attach source to existing JAR files in Eclipse. Refer this SO post: Is there an easy way to attach source in Eclipse?
For this specific dnsns.jar, it is part of your JRE, and if you are not able to see its source in your IDE, then it means that the Java that you have setup in IDE lacks the source. If your installation does not have the source (src.zip), then you can get it manually as mentioned on this SO post: Where to find Java JDK Source Code?
EDIT: Alternatively, you can also use a decompiler (e.g. http://jd.benow.ca/) to reverse engineer the source from byte code, though, it may not be the exact match to the original source but you can understand the overall idea. You can add the decompiler as the default program for opening .class files in eclipse Windows > Preferences > General > Editors > File Associations. Select *.class filter and add your decompiler as the program. Though, it is not as clean as attaching the source to JAR, but may work if you don't have access to source.
EDIT2: About your question
What's the difference between included Jar file and a pure code
Eclipse can find .java files for your own code because obviously they are in your workspace. But when you add a JAR file as library, it may have the source (.java) in it or not. If the source is available, eclipse can display it by default. If not, you have to add it manually.
I have extracted a .class file from the rt.jar file in jre1.7, and have attempted to open it using notepad++, however it is unreadable. How can I decompile the .class file into a .java file so I can view the code?
Please note that I am interested in the decompilation of the code, not viewing the source code provided in the JDK downloads.
As #Jon Skeet said, don't use JRE but JDK, which contains the entire source code. If you for some reason insist on your approach, then I recommend JD-GUI for decompilation.
.class files are the compiled binary files. You can't read the Java code from them, but you can run them. If you want to see the source you usually need .java files. These are either packed in the same jar but then the src folder, or they can be downloaded in a seperate package.
You can use any decompiler tool like cavaj for decompiling a class file to source code (java file). I'm using it, and it works perfectly.
Try any of the decompilers listed here:
Procyon - https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler
CFR - http://www.benf.org/other/cfr/
JD - http://jd.benow.ca/
Fernflower - https://github.com/fesh0r/fernflower
Or use online decompiler - http://www.javadecompilers.com/
So I want to view PDFs in my app and I've come across APV PDF, but I just can't understand the instructions on how to use it
http://code.google.com/p/apv/wiki/Building
Why isn't it a jar library to download?
Why do I have to compile some .so files, why can't I download them?
I browsed the source and there is a demo application here:
http://code.google.com/p/apv/source/browse/#hg%2Fpdfview
I copied that into eclipse as an Android project and it compiles but I get an error when I run and select a PDF in the compiled app
java.lang.UnsatisfiedLinkError: parseFile
I understand this has something to do with what I've asked above, so hopefully I'll get some answers.
This probably has something to do with the NDK which I have no experience with.
My mind has been expanded!
1) You can't have a Jar as this is C code, so it is going to run in the NDK therefore the equivalent is a .so file.
2) I don't know why they don't let you just download an .so file (as well as having the source), but it seems this project is just a starter project i.e. you are expected to take the source and modify it. Therefore if you just had a .so file you could not do this. Each time you change the source code in /jni/pdfview2 you have to rerun the script build-native.sh and that will recreate your library (.so) files for you!
I was getting the UnsatisfiedLinkError as the .so library I was using was built against a different version of the code than that which the Java file was trying to reference. Therefore my link was un-satisfied!
Hazar!
I'm currently working on a Java project which uses Tibco rendezvous control.
I have the tibrvj.jar file on my build path. But I'm not able to see the classes which are there in the package "com.tibco.tibrv".
This package is in the jar which is on my build path.
When I try to open the class in that package , the message displayed on class editor is : "Source not found. the jar file tibrvj.jar has no source attachment".
Is there anything that could be done to set it right ?
This looks like an IDE specific message. Which IDE are you using?
The jar in your classpath only contains the java classes (bytecode) and not the source files (.java files). It looks like you are trying to open the class in your IDE/editor. Since you do not have the java files corrsponding to these classes, the editor is comlaining.
As these are Tibco specific classes, the only option is to "decompile" the classes to see the corresponding java code. Consider using a decompiler like DJ Java Decompiler
It depends on what you mean by "I'm not able to see the classes." If you mean you're getting build failures, that's possibly a matter of not actually having it properly in your build path (how are you building?) or maybe not having the right imports.
If you mean you can't see the source code, you'll need to get hold of it somehow (is Tibco open source?) and then configure your IDE so that it knows where the source is. Of course you don't need to source just to be able to build your app which uses Tibco.
If you could give more information about exactly which problem you're facing, along with what IDE you're using (if any) we could probably help more.