Running Hierarchy Viewer - java

I am trying to run Hierarchy Viewer. developer.android.com says to
"Connect your device or launch an emulator.
From a terminal, launch hierarchyviewer from your SDK /tools directory."
I tried finding the hierarchy viewer in sdk/tools, but couldn't find it. I realize my difficulty may just be the result of me being a total noob so I could just be missing something basic.
How do I run hierarchyviewer?
Thanks!

(Sorry, I was meant to add this as a comment to Mayra's answer below)
I was using SDK_r06 and HierarchyViewer.exe was in the /tools folder.
I upgraded to SDK_r07 (using Android SDK and AVD Manager) and now HierarchyViewer.exe is not in the /tools folder.
I re-downloaded the SDK from the Android website and it is not in the /tools folder.
Has it been left out of the SDK_r07 release of the SDK?

in your tools directory create a file named hv.bat
and add this code to that
java -Xmx512m -jar ./lib/hierarchyviewer.jar
its a problem with windows file directory, but we know that hierarchyviewer.jar is in lib!!!!
or here is the original batch http://groups.google.com/group/android-developers/browse_thread/thread/30124afa7a708c96/c51b4fc2e979a721

Just had the same issue. It looks like version 7 of SDK Tools does not include the executable for unknown reason (you may download the SDK and see that it's not there). Therefore, an update removes the executable even if it was there before. However, the executable is not an *.exe, but just a *.bat, which uses the HierarchyViewer.jar in the lib folder.
So I just copied the hierarchyviewer.bat file from the 6th version into the tools folder and it worked.Note, that you have to type hierarchyviewer or hierarchyviewer.bat to start it, not hierarchyviewer.exe.

I assume you are on windows.. to open a terminal window run start -> run and type "cmd". You should see a black window with a cursor.
You need to open the tools directory by typing cd C:\full\path\to\tools\directory filling in the path to where you installed the sdk.
If you type dir you should see a list of files located within the folder, one of which is hierarchyviewer.exe. Run that file (just type hierarchyviewer.exe)

launch your cmd if you on windows then type
cd\C:\android-sdk-windows\tools then enter now you are in tools folder then type hierarchyviewer
then enter , now you should see hierarchyviewer
and here's alink of how to open it and use it http://developer.android.com/guide/developing/debugging/debugging-ui.html and also good article
http://mobile.tutsplus.com/tutorials/android/android-tools-using-the-hierarchy-viewer/

Related

How do I add LWJGL 3.1.1 to netbeans to use in a Java project?

I want to use the Light Weight Java Gaming Library(LWJGL) to my Netbeans so I can use it in my Java application. The only videos that I can find show the zip file that they downloaded with separate src and doc folders inside of it. The zip file that I download has everything in one directory. I went to lwjgl.org/download and clicked on Stable and then Generate Bundle. What am I missing?
I had the same problem recently.
So, to begin you want to go to Tools in the context menu and select Libraries (as shown). Next you can add a new library and name it e.g. LWJGL-3.1.1 confirm with ok. You can find 3 tabs in the current window Classpath, Sources and Javadoc. There you add your jar files accordingly (in the downloaded .zip file you find .jar files with different names like lwjgl-{whatever}-sources.jar or lwjgl-{whatever}-javadocs.jar) make sure you put them in the right place. You have to repeat this process for all of the jar files you want. The javadoc files are not required but recommended. Make sure you also collect all the native .dll files and merge them in a folder called \natives. You find them in these jar files that are called like: lwjgl-{whatever}-{your-OS}.jar.
Once you have finished the setup for your library right click on your current project and choose Add Library.... In the window that pops up you scroll down until you find your library that you have just created and you are almost done now.
Last but not least go to the project settings. Select Run and make sure that you set the classpath in VM options to something like in the image: -Djava.library.path="C:\java_workspace\LWJGL Library 3.1\natives. Now this classpath tells netbeans where your native files are located. Your \natives folder that you should have created in the beginning is where this path should lead to. That's it. This is all you have to do for a setup without the use of maven, gradle, ...
You can test if it is working with the code provided by LWJGL HelloWorld example.
I hope this solved your problem.
Best regards.

NeuronJ plugin in ImageJ .JAR file not opening on MAC OSX10.10.4

I am trying to download and add a specific plugin called NeuronJ to ImageJ. ImageJ downloads fine and I can open it. The .JAR file for the NeuronJ plugin downloads but does not open and the MAC gives me the following message 'The Java JAR file NeuronJ.jar could not be launched, check the console for possible error messages'. Would anyone know how to solve this problem? The website I am using to download this from is:http://www.imagescience.org/meijering/software/neuronj/
NeuronJ.jar is an ImageJ plugin - so you don't execute it directly. You put it in a place ImageJ will find it on startup (the {ImageJ}/plugins directory). Directions for manual installation can be found on the wiki.
Once you install the plugin manually you just restart ImageJ and then NeuronJ should be available from the Plugins menu.

How to correctly build Jsoup.jar and export it to be used by Android APP

The current Jsoup release 1.7.3 has a known issue that it is using String.isEmpty() which is not supported by Android API Level 8.
I can see crash report of my app so I tried to fix this by change the source code of Jsoup and build my own jsoup.fix.jar. I test this jar with JAVA application and it worked fine on my PC.
I noticed that when I remove the original jsoup-1.7.3.jar from my project, there is errors complaining cannot find jsoup stuff, and the those errors are gone after I add the jsoup.fix.jar which seems to be good. I also check the JAVA build path and the exporting configurations, jsoup.fix.jar are all set as it should.
However, when I tried to run the APP on my Android devices, the APP crashed and saying it cannot find org.jsoup.Jsoup.
I checked the jsoup.fix.jar, opened it with JD-GUI and find the classes are all there, but I used my dex2jar to convert the classes.dex in my /bin directory, I cannot see nay org.jsoup stuff.
Just replace my jar file with the original jar will not have the same issue reproduced.
I also noticed that in my jar, the MANIFEST.MF file only have one line of content, but in the released jsoup-1.7.3.jar, the MANIFEST.MF contains a lot of content.
I am confused now, questions:
Am I doing wrong when build my own jar?
Why the APK still cannot include the jsoup pacakage even I configured it to do so?
Finally I found the reason might be the jar is exported from a JAVA project.
I have tried to create an Android project and copy the source files into it and then export another jar file, and it works!
Could anybody explain why?

Java App unexpected behavior when exported

I have a very strange problem, that I can't figure out, the thing is that my aplication runs perfectly on the IDE (Eclipse), but not when exported, when I run the jar (double click) the aplication start but some functionality is missing (loading from a template file, but this does not happend when loading from a normal file), when I try to run it from console (java - jar my.jar) in order to see any error message it turns out that my aplication works perfectly fine! :S ...
Some more info:
My app is running over windows 7
I start the task manager, and I noticed that when I start my aplication using double click its under the name java.exe *32, and when I do it from command line its under the name java.exe (without "*32"), as far as I know I programmed nothing related to a 32 or 64 bits functionallity.
"Solved"
Well I was not able to solve it the way I wanted, as far as I was able to find, i found that there were a problem between the 2 java versions I was running x32 & x64, I deleted the 32 bit version and it start working as a charm, but I'm still not sure about what happend, I give my thanks to #Sajal Dutta one of its comments help me to understand part of the problem, thanks to all of you anyway, I'll keep searching until I find the problem...
When you create a jar from Eclipse, your assets don't get copied over to jar or location is not preserved. Open the jar and check if you have your templates in the right location or you have it at all.
To have the exported jar include your assets/resources-
Right click on your project in Eclipse. Then New -> Source Folder.
Name the source folder anything. e.g. template_src.
Copy or drag the entire directory of your template to template_src. Then make the jar.
Since it works via the command line but not when double-clicking the jar, it is likely that the working directory is different (and that you're loading the template with a relative path). When you run an executable jar by double-clicking, on some operating systems, the working directory is the home directory whereas when you run from the command line, it's the directory you're currently in.
The "files" in the jar are not handled by File, but are resources;
URL url = getClass().getResource("...");
InputStream in = getClass().getResourceAsStream("...");
Then, the file paths inside a jar, or on a non-Windows platform are case-sensitive.
"Template_A.xml"
is not
"template_a.xml"
Also you might inspect the jar with 7zip or WinZip.

How to get Java Decompiler / JD / JD-Eclipse running in Eclipse Helios

Java Decompiler (JD) is generally recommended as a good, well, Java Decompiler. JD-Eclipse is the Eclipse plugin for JD.
I had problems on several different machines to get the plugin running. Whenever I tried to open a .class file, the standard "Source not found" editor would show, displaying lowlevel bytecode disassembly, not the Java source output you'd expect from a decompiler.
Installation docs in http://java.decompiler.free.fr/?q=jdeclipse are not bad but quite vague when it comes to troubleshooting.
Opening this question to collect additional information: What problems did you encounter before JD was running in Eclipse Helios? What was the solution?
Here's the stuff I ran into:
1) RTFM and install the "Microsoft Visual C++ 2008 SP1 Redistributable Package" mentioned
at top of the installation docs. I missed this at first because the Helios instructions are at the end.
2) Close all open editor tabs before opening a class file. Otherwise it's easy to get an outdated editor tab from a previous attempt.
3) Open the class file in the "Java Class File Editor" (not "Java Class File Viewer"). Use "Open With" in the context menu to get the right editor. If pleased with results, make it the default editor in the File Association settings, in Window/Preference General/Editors/File Associations select *.class to open with "Java Class File Editor".
4) This guy recommends installing the Equinox SDK from the Helios update site. I did, but I'm not sure if this was really necessary. Anyone know?
5) If the class files you are trying to view are in an Eclipse Java project, they need to be in the project's build path. Otherwise, an exception ("Not in the build path") will show up in the Eclipse error log, and decompile will fail. I added the class files as a library / class file folder to the build path.
6) Drag/dropping a class file from Windows Explorer or opening it with File/Open File... will not work. In my tests, I gives a "Could not open the editor: The Class File Viewer cannot handle the given input ('org.eclipse.ui.ide.FileStoreEditorInput')." error. That is probably the wrong editor anyways, see 3).
7) After getting the plugin basically running, some files would still not decompile for an unknown reason. This disappeared after closing all tabs, restarting Helios, and trying again.
To Make it work in Eclipse Juno - I had to do some additional steps.
In General -> Editors -> File Association
Select "*.class" and mark "Class File Editor" as default
Select "*.class without source" -> Add -> "Class File Editor" -> Make it as default
Restart eclipse
The JD-eclipse plugin 0.1.3 can only decompile .class files that are visible from the classpath/Build Path.
If your class resides in a .jar, you may simply add this jar to the Build Path as another library. From the Package Explorer browse your new library and open the class in the Class File Editor.
If you want to decompile any class on the file system, it has to reside in the appropriate folder hierachy, and the root folder has to be included in the build path. Here is an example:
Class is foo.bar.MyClass in .../someDir/foo/bar/MyClass.class
In your Eclipse project, add a folder with arbitrary name aClassDir, which links to .../someDir.
Add that linked folder to the Build Path of the project.
Use the Navigator View to navigate and open the .class file in the Class File Editor. (Note: Plain .class files on the file system are hidden in the Package Explorer view.)
Note: If someDir is a subfolder of your project, you might be able to skip step 2 (link folder) and add it directly to the Build Path. But that does not work, if it is the compiler output folder of the Eclipse project.
P.S. I wish I could just double click any .class file in any project subfolder without the need to have it in the classpath...
I am using Eclipse 3.7 Indigo and Windows 7 64-bit:
What I did was to install the Microsoft Visual C++ 2008 SP1 Redistributable Package as suggested by the site and reminded by #Universalspezialist.
Then install the plugin as stated in the site: http://java.decompiler.free.fr/?q=jdeclipse
Go to preference, then find "File Associations"
Click on the *.class, then set the "class File Editor" as default.
Restart Eclipse perhaps? (I did this, but I'm not sure if it's necessary or not)
Simple thing i did to get it working:
Went in eclipse > Window > Preferences
(Optional)typed in the search box "file" to help trim the tree of options.
Went to General > Editors > File associations.
Clicked the ".class" type. Below there were 2 editors present, i clicked on the "Class File Editor" - the one with the icon from JD, clicked the "Default" button on the right.
Done.
Now all ur class are belong to us.
After testing on Juno, Kepler and Luna, I found JD only works for *.class files on build path.
Adding the jar as a lib of an existing project
Go to Preferences->General->Editors->File Associations, set *.class without source to Class File Editor with a cup icon
Its should work for all version of eclipse even in Spring tool suit(STS).
Here is the steps
Go to the URl
Follow The link to download or click the bellow link to direct download
Click Here to download
Download JD-Eclipse.
Download and unzip the JD-Eclipse Update Site,
Launch Eclipse,
Click on "Help > Install New Software...",
Click on button "Add..." to add an new repository,
Enter "JD-Eclipse Update Site" and select the local site directory,
Select extracted folder and give any name. I have given JDA.
and click ok.
Check "Java Decompiler Eclipse Plug-in",
Next, next, next... and restart Eclipse.
I use jadeclipse instead, because it can't work in 3.6/3.7 eclipse
Update site
http://webobjects.mdimension.com/jadclipse/3.6/
Intallation
http://5thcross.wordpress.com/2009/05/20/installing-jadclipse-in-eclipse/
JAD Decomplier plug-in for Eclipse version 3.x and 4.x.
update site: http://feeling.sourceforge.net/update
Steps:
Open Eclipse IDE.
Click Help->Install New software
Paste above URL and give name as JAD.
Select the Eclipse Class Decompiler
Click on Next and accept agreements
Install it.
Restart Eclipse and check now.
if you need to decompile standalone jar try JD-GUI by the same autor (of JD-Eclipse). It is a standalone application (does not need eclipse). It can open both *.class and *.jar files. Interesting enough it needs .Net installed (as do JD-Eclipse indeed), but otherwise works like a charm.
Find it here:
http://jd.benow.ca/
Regards,
I made the steps 1, 2, 3 and the 7. and I put the folder with the class files in the project build path (right click, properties, java build path, libraries, add class folder, create new folder, advanced>>, link to folder in the file system, browse,...) then restart eclipse.
Download the JD-Eclipse Update Site(github.com/java-decompiler/jd-eclipse)
Launch Eclipse,
Click on "Help > Install New Software...",
Click on button "Add..." to add an new repository,
Enter "JD-Eclipse Update Site" and select the local site directory,
Check "Java Decompiler Eclipse Plug-in",
Next, next, next... and restart Eclipse.
Just download the site from the JD page. I was able to install from a local site in the isntalled software section of eclipse.
Steps to add the Java Decompiler in Eclipse :
Open Eclipse IDE.
Click Help->Eclipse Marketplace Wizard
In Search tab find the JD (JD is keyword to get the Eclipse Class Decompiler)
Select the Eclipse Class Decompiler
Click on Install.
Restart Eclipse and check
I used Intellij or Android studio both are working awesome for decompiling purpose.
Internally Intellij following FernFlower Decompiler.

Categories

Resources