Getting WinMerge to compare .jar files - jar

I have two directories which contain a handful of *.jar and *.war archives, as well as some metadata files and a file with *.spring extension, which is really just a zip file with an odd name. Something like this:
- dist1
- a subfolder
- some text file.txt
- application-context.xml
- arch1.jar
- arch2.jar
- arch3.jar
- super-cool.war
- xtremely-awesome.spring
- dist2
- a subfolder
- some text file.txt
- application-context.xml
- arch1.jar
- arch2.jar
- arch3.jar
- super-cool.war
- xtremely-awesome.spring
I'd like to do directory comparison on these directories, comparing the archives as if they were subfolders rather than binary files. Other files, both text and binary files both outside and inside the archives, should be compared as usual.
I know I could just explode all the archives manually and compare the exploded versions, but since they are generated by a build script and exploding them adds a considerable amount of time for building the project, it would be nicer to just do it for the comparison, preferrably within the diff tool.
I've tried using WinMerge with the 7zip plugin, but I can't get the plugin to work (the files are not recognized as archives in the folder compare view). I've tried both installing as a "shared installation" and as an "application specific installation" (pointing the installer to C:\Programs\WinMerge\WinMergeU.exe). I've also tried manually copying the .dll files from the plugin into the MergePlugins folder, without success.
How do I get this working in WinMerge? And if it's not possible, is there some other good tool that has this capability?

Since WinMerge 2.15.2 (2018-01-28), archives are supported out of the box. See the change log section "Archive support" for changes to the functionality.
For the 2.15.2 release, the changelog says:
Archive support
Install 7-zip plugin by default
Options dialog
...
Remove "Use stand-alone 7-Zip if available" and "Use local 7-Zip from WinMerge folder" radio button from "Archive Support" page (Now always use local 7-Zip from WinMerge folder)
...
In WinMerge 2.14.01, the easiest way to enable archive support is to
download the 7-Zip plugin for WinMerge2,
use its installer to install the DLLs and related components for the latest 7-Zip supported into the folder of WinMerge3 (select the “Application specific installation” and “Enable standalone operation”), and
change the WinMerge settings to use these files and detect archive type automatically (in “Options → Archive Support” select “Enable archive file support”, “Use local 7-Zip from WinMerge folder” and “Detect archive type from file signature”).
Image and the solution are by jtuc, the developer of WinMerge. I found them in a WinMerge forum thread.
Then, if you compare two JAR files (or files in any other archive-based format, e.g. ODF or OOXML), their contents should be compared as if they were extracted first. It works for me on Windows 10.
Some details on installing archive support are mentioned in the WinMerge manual.
1 WinMerge 2.14.0 is the latest stable release as of 2017-06, released on 2013-02-03.
2 Merge7z DllBuild 0028 is the latest as of 2015-09, released at 2010-12-28.
3 The DLLs are Merge7z920.dll and Merge7z920U.dll for 7-Zip 9.20 in Merge7z DllBuild 0028, and the path to WinMerge executable is probably C:\Program Files (x86)\WinMerge\WinMergeU.exe. The “U” stands for Unicode in both the DLL’s and executable’s name. For WinMergeU.exe, only Merge7z920U.dll is needed, but better have both and don’t have to care.

WinMerge FAQ section 6.4:
Can WinMerge open archive files with non-standard file-extensions?
(For example .jar files as zip-files)
Yes: click the Options button
(or click Edit → Options). In the Archive Support page, enable the
Detect archive type from file signature option.

If you want compare difereneces directories with files type *.jar, *.war , *.ear..etc a good options is beyond compare software http://www.scootersoftware.com/. Is not free but you have a trial option to prove it. It is multi-platform linux, windows or macosx.

Related

How do I edit a symlink using Atom?

On GitHub I can view symlinks as text - they are just a path to the target.
However, if I edit a symlink in Atom it opens the file that the symlink points to. This is reasonable behaviour but not what I am trying to do.
Can I edit them in a similar way using Atom on my local machine?
If now, is there another text editor that can?
You can't change a symbolic link's target by editing the symlink file.
There are cases where the target of a symlink is stored in the symlink file, but that is not usually the case. For most target paths, the target is stored in the inode data directly.
Then there are symlink-like things various filesystems have implemented, such as macOS aliases, or Windows NTFS which has symlinks but they are not exactly the same as Unix/POSIX symlinks.
To manage symlinks you should be using the tools your OS provides, such as the ln command.
That said, I'm not aware of any packages for Atom which offer an in-editor method of managing symlinks. The tree-view package does not seem to offer it.

How to tell atom that a directory includes project source code?

Atom seems to assume that certain folders are non-project-source folders and thus should not be included in search results and fuzzy finder (cmd+t). I've noticed the following folders are treated this way and the text for these folders are also displayed darker in the file tree:
node_modules
lib
log
That's all fine and dandy, except that I have a lib folder that is in fact important project source code that I would like to access via fuzzy finder. Is there a way to instruct atom to include the lib folder in fuzzy finder results?
The Fuzzy Finder ignores files that are ignored by your VCS (Git in your case?) by default.
You can change that behavior by removing the check on the "Exclude VCS Ignored Paths" checkbox in the general settings:
In your case, is the lib folder part of your .gitignore file? If it is, then Atom wouldn't include it in its search results.

How to share/transfer an Atom installation (packages and settings) from one Mac to another?

Is it possible to copy Atom from one Mac to another, including all installed packages, settings etc?
There are several ways to synchronize your settings and packages between Atom installations:
Git: Create a public or private Git repo and store the contents of your local ~/.atom folder in there. Ignore the following files/directories in a .gitignore file:
storage
compile-cache
dev
.npm
.node-gyp
Use a package like sync-settings. This will store your configuration in a GitHub Gist.
Dropbox (or similar): Move your ~/.atom folder to your Dropbox folder and then symlink it from there to its original location. This has the downside of syncing everything in ~/.atom, even the things you could ignore.
Use stars to select your favorite packages. On the Atom web site, create an account and mark your favorite packages with stars. Then use apm stars --install to install all starred packages on any machine. Downside: This only works for packages, not for settings.
More details:
https://discuss.atom.io/t/syncing-settings-packages-between-machines/1385
As a user who uses a dotfile management system such as RCM, I prefer independent config files.
For now, Atom doesn't officially provide a packages.cson file to manage plugins, but as the post Syncing settings & packages between machines mentioned, there is a plugin called package-sync that will generate a packages.cson file for us.
So with the help of package-sync, now I can just sync those mininal config files to have my Atom settings and packages consistent across multiple machines.
This is how to do it (Use ubuntu as an example):
Install Atom, and install package-sync through Edit-->Preferences-->Install as the screen shot shows:
Open your command pallete and type: Create Package List and there will be a packages.cson file under your ~/.atom folder.
Edit the gitignore file:
$ gedit ~/.atom/.gitignore
Make sure the content is:
blob-store
compile-cache
dev
storage
.node-gyp
.npm
.apm
packages/
atom-shell/
This is a screenshot of the .gitignore file:
This makes sure the content downloaded by Atom from the Internet will not get synced to your dotfiles repo.
Move the .atom folder to the dotfile repo:
$ mv ~/.atom ~/dotfiles/tag-atom/atom
Relink the folder:
$ ln -s ~/dotfiles/tag-atom/atom ~/.atom
Or if you have rcm installed:
$ rcup
Now go to another machine, and install Atom and package sync. Update your dotfiles repo, and then Open your Atom command pallete and type: sync
Now your Atom settings will get synced and integrated with the RCM dotilfe management system.
This is the files in my ~/.atom folder that get synced:
I recently built a package that syncs automatically your Atom settings and packages across multiple computers. A little bit like the bookmark synchronization mechanism in Google Chrome. It's called atom-package-sync. Maybe it could fit your needs.
You can sync your packages via package-list.txt file and a simple shell script.
Create the package-list.txt file
apm list --installed --bare > package-list.txt
Install missing packages on another host
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALLEd_PKGS=$(apm list --installed --bare)
for PKG in $(cut -f1 -d# $BASEDIR/package-list.txt); do
grep -q $PKG <<< $INSTALLEd_PKGS || apm install $PKG
done
The .atom folder contains the packages folder, which can be rather huge. Unfortunately OneDrive doesn't allow you to exclude folders, so I went with a git option.
I excluded the packages from git and instead I committed a text file containing my packages (my-packages.txt).
To re-install packages I need to run: apm install --packages-file my-packages.txt.
To generate the my-packages.txt, I need something like this on a Bash shell: ls packages | xargs -n 1 echo | cut -d/ -f1 > my-packages.txt
I sync my Atom settings between Windows, macOS, and Linux machines using Resilio Sync Home. It is free and the files are not saved on the "cloud" (like Dropbox or Gists), but it requires that, at least, two machines are online in order to sync the current settings.
I do not want to sync caches, installation specific settings, et al., I update the .sync/IgnoreList file that is created in the synced directory (i.e., the ~/.atom directory). Unfortunately, you will have to update this on each machine that you sync (ironically, the IgnoreList file is not synced). By default, the file specifies various temporary files to be omitted from syncing, so you'll need to add the following:
## Atom-specific
/packages/node-debugger/debugger.log
\packages\node-debugger\debugger.log
/.apm
\.apm
/.node-gyp
\.node-gyp
/.npm
\.npm
/blob-store
\blob-store
/compile-cache
\compile-cache
/dev
\dev
/recovery
\recovery
/split-diff
\split-diff
/storage
\storage
Some of the omitted directories are package-specific (e.g., split-diff). Because Windows has different path delimiters than other platforms, I need to specify both(!!)
Install Resilio Sync Home on your first machine
Add the .atom directory to Resilio to be synced.
Update its IgnoreList file, as shown above. Save this file for the other machines you want to sync with.
Send a Resilio "Read & Write" link of that folder to the other machines you want to sync with or copy the "Read & Write" key to be used on the other machines. To do this, in Resilio's folder view, click on the .atom folder's menu (vertical dots on the right edge) and select "Copy Read & Write key". Save it for later.
Then on your other machines,
Install Resilio Sync Home
Create .atom/.sync
Copy the IgnoreList from your first machine to that directory
Add the .atom directory to be synced with the other machine. You should add the folder using "Enter key or link," then enter the key you copyed, above.
Wait until syncing is done before opening Atom. The first time will may take a few minutes.
Now I don't need to go around installing/removing packages on every machine, separately!
FYI: Changes to files and directories are saved in .sync/Archive, for some period of time, if you should need to recover them.

Self executable Jar File not executable after installing Winrar

Here's the deal, I've compiled a few classes into a jar file with a manifest pointing to the main-class. It works just fine on my computer.
I transferred the jar file onto another computer which I'm supposed to give a demonstration tomorrow on and well, here's where things went downhill.
Winrar was not installed, so I installed it in order to extract the folder I had my jar file in. I unknowingly associated winrar with jars which I fixed by changing the default open program with jre7/bin/java.exe. However, the jar file does not self-execute as it did previously. I'm thinking something's up with the registry.
Stackoverflow, what do you think?
I guess a simple solution would be reinstalling the JRE.
You need to reset file association for ".jar" files, jar files are not executed by "jre7/bin/java.exe". so what you should have done before choosing default program to "jre7/bin/java.exe" was to simply uninstall WinRAR or remove its association from the WinRAR settings. So now, open start menu, search and open regedit.exe goto HKEY_CLASSES_ROOT/.jar and delete every value excluding "(Default)" who's value data should be "jarfile". the reinstall jre and reboot pc . THAT'S YOUR SOLUTION.

How do I find the packages defined in a jar?

I have a bunch of JAR files (from a maven2 project) and maven reports some package could not be found (org.openanzo.client.jena to be exact). I want to dig into the JAR files downloaded as the result of maven dependency resolution and find what packages are thus available from these JAR files. Insights?
UPDATE: Apparently, the only good solution to inspect insides of a jar file is the "jar" utility or one can use the facilities of their IDE to do so.
jar tvf filename.jar will show you the contents of a jar file without requiring you to extract it.
But I think that maybe what you are really trying to do is find the right coordinates for the dependency that you are missing, since obviously none of the ones you have right now are supplying the package you are looking for (in other words, checking their contents is not likely to help you).
I confess that the first place I would suggest to check is Sonatype's public Nexus instance. A search for your example turns up nothing, though. Usually that means the project is not trying to get their stuff into Maven Central or other major repositories (which is okay), so you have to resort to a web search. Usually the first two sections of the package tell you where to look (openanzo.org in your case).
If you are on Linux or a Mac, you could go to the terminal at the root of the folder containing your JARs and type:
# grep -ri "org.openanzo.client.jena" *
It will return a recursive list of all JAR files that contain that package name. If it returns 0 results, then none of those JARS contain that package.
If you wanted to do a more exhaustive search, you could unJAR the JAR files. The directory structure and .class files will be organized by packages in folders.
# jar xvf filename.jar
If you are on Windows, you can unJAR a JAR file using a tool such as 7Zip.
#Carsten
you do not have to rename a .jar file to .zip. You can directly open the jar file in winzip/or other zip utility (assuming windows OS)
#ashy_32bit
try using "jar class finder" eclipse plugin from IBM. Simple plugin for finding classes (if you know the class name)
OR
as carsten suggested... set the jar files as lib files and manually look it up
OR
create a batch file called a.bat (where you have all your jar files directly under a single folder) and paste the following 4 lines
#ECHO OFF
dir /b *.jar > allJarFilesList.txt
FOR /F %%A IN (allJarFilesList.txt) DO jar -tf %%A > list_of_packages.txt
FOR %%B IN (list_of_packages.txt) DO FIND /I "com/sun" %%B
NOTE the "com/sun" in the last line.. it is hard coded, you can pass as argument as well...
I know this is very basic form and can be improved "a lot" like looking up in various sub directories.
hope this helps :-)
.jar files are just ZIP compressed archives, rename it to zip, open it with your favourite unzip programm, and traverse through the directory.
If you add the jar file to a eclipse project, you can traverse through the lib in th project explorer.
HTH
Assuming maven downloaded the jar files,the files will be loaded in to a local repository.
You could use maven browser that comes packaged with Eclipse to browse and search for artifacts in your repository.(usually in userdir/.m2/repository)
Note:You can explore your repository directly if you want. You will understand the packages that were downloaded. But I suggest using the plugin.
If you are using Intellij IDEA, each project contains a tree called External Library that allows you to search and explore your libraries.

Resources