Is there a way, from Java/Scala code, to retrieve the version of Avro library? - avro

I'm not 100% sure that e.g. version 1.7.7 of Avro can read files produced by 1.9.2 or 1.8.2. So I'd rather keep somewhere in meta information the version of avro that was used when creating a file.
But I don't see how it is possible, without tweaking build files and creating some kind of resource (it's pretty simple in gradle).

As you can see in Get jar version in runtime, version can be retrieved, at least when it's provided.
So, in this specific case, the following line:
(new org.apache.avro.Schema.Parser).getClass.getPackage.getImplementationVersion
Returns a version string; in my specific case it is "1.7.7".

Related

MVC Bundle {version} when old file still exists in directory

In MVC 4, using the Bundles to define the files you want to include, you can use a {version} wildcard, for example...
"~/Scripts/jquery-{version}.js"
This works well when you have one version in the folder, e.g. jquery-1.7.js. However, when we have two versions in the folder jquery-1.7.js & jquery-1.9.js, it seems to pick up the old version, ignoring the new version.
Does the {version} wildcard find the first instance, and then move on? if so, the first instance in this example seems to the be the old version (as 1.7 comes before 1.9). So, is there a way of forcing it to look for the newest version if we have two files?
NOTE: The above version numbers may not be accurate, just used for scenario purpose.
In Mvc. It will load the old version first and then latest version. following will be sequence of jquery file load.
1.jquery-1.7.js
2.jquery-1.9.js
In this situation . latest file will overwrite the old version. so your page always get latest jquery functionality.
We ended up using something similar to this post, which tackles a similar issue. I will update the answer with a full description and code in the next few weeks once implemented fully.

Java JRE: How to add localized resources to stantard JRE resources

I need the JRE to use translated versions of a JRE resource that is available only in English.
As per the ResourceBundle.java doc, it's easy: add localized resources with the right locale suffix. For example, the standard
XMLSchemaMessages.properties
would become a translated version:
XMLSchemaMessages_FR.properties
And so on.
EDIT: this particular file lives in :
com\sun\org\apache\xerces\internal\impl\msg\XMLSchemaMessages.properties
My question is: how do I make those extra resources visible to the JRE ?
Thanks in advance, for any help.
-- cheers
Assuming that Xerces uses ResourceBundle to get the messages, you should put a new file in
com\sun\org\apache\xerces\internal\impl\msg\XMLSchemaMessages<locale>.properties
where locale is a correct identifier for the locale you need.
Then pinpoint the exact location where the XMLSchemaMessages resource bundle is loaded, and set a breakpoint so you single step through the ResourceBundle loading procedure in the JRE (a JDK is recommended here, so you have source for the runtime) and you can see what is being searched for.
Note: You are dealing with a vendor specific XML Parser here meaning this will be Oracle specific and may even only work on some Java versions. Considered bringing in your own validating XML Parser and localize it instead?
The above answers took me a little while to work out.
Just to make it easier for others, here's my summary of how to get Locale specific error messages to appear if you try parsing an XML document using XML schema with Java's internal Xerces parser:
Find an appropriate properties file in the format
XMLSchemaMessages_<lower_case_language_code>.properties
For Italian I found XMLSchemaMessages_it.properties on the following site (which might be an old version, but it worked for me)
http://grepcode.com/file/repo1.maven.org/maven2/com.sun.xml.parsers/jaxp-ri/1.4.5/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_it.properties
I then created a directory structure in my temp directory to hold the new file
com\sun\org\apache\xerces\internal\impl\msg
Since jar files and zip files share the same format (and I'm lazy and today I was using Windows), I then zipped the above com directory, creating a file called com.zip. I then changed the name of the file
rename com.zip to XMLSchemaMessages_Locale.jar
and then moved the new jar file to
C:\Program Files\Java\jdk1.7.0_04\jre\lib\ext
Of course the above path depends on your platform and specific version of Java (I was using Windows 7).
Instead of zipping, if you have JDK you could easily build the jar file using the command-line jar command, from Unix, Linux or Windows.

How to use project version information inside a Delphi application?

I use Project Options / Version to manage the version info (N.N.N.N format).
Anyway inside my project I duplicate those info.
So if in project options I am working on release 2.4.3.178
inside my application I have 4 integer variables that hold the 4 numbers.
I manually set them
Major := 2;
Minor := 4;
Release := 3;
Build := 178;
The reason of this is simple: I have licensing based on version number. So if the user buys release "2.4" it is not allowed to upgrade to version "3.0".
But if I rely on project version info the user can (with Resource Hacker tools) change the version info and therefore "activate" the product.
The user cannot change the 4 variables in the same way (not as easily at least).
This works but forces me duplicate the info.
Could you suggest a better approach?
Otherwise said: is there a way to write the version info using the data I write in those 4 variables. Something like in Post Build Events, but how do I pass data to post build events?
You'd need a pre-build event rather than a post-build event since you'd want to get the .res file built before linking.
I do something very similar with a simple Perl script that reads an include file (.inc) containing constant declarations of the version numbers. I read them in using a regex and then create my .rc file which I pass to brcc32. It's all invoked as a pre-build action.
Since you're on Delphi-XE and have Final Builder, why don't you put it to good use and make your "final" build from it? It can give a very nice solution to the version number problem, and can do a lot more.
Here's how I'd do it.
Set up a small INI file that holds the relevant parts of the version information.
Optionally make a small Delphi forms application that reads the version number from the INI files and gives you a chance to change it. When changes are saved to the INI file, the delphi application should automatically generate a small Delphi PAS file that defines the constants!
Create a FinalBuilder project that does the following:
Calls your Delphi exe to set up version number. You'll be in charge of changing whatever needs changing, and this is probably appropriate since your licensing scheme depends on version information.
Set up a few project variables to hold the version information numbers
Add "Read INI file" actions to read the version information from the ini files into your project variables.
(optional) Build the unit test project, if you have one.
(optional) Call the unit test project.
Add a "build Delphi project" action, set it up to build your project using whatever options you need. Add a small "Before" script to set up the version information numbers to what you've got in the project variables you just read from the INI file.
(optional) create setup packages using whatever tool you use.
(optional) upload those setup packages to a website.
In other words, take the opportunity to start using Final Builder.
Moving your version numbers into code is also easy to get around.
One way to pass the information is to generate a version.rc file programmatically (you write a tiny build tool yourself using delphi or a scripting language of your choice), and link the resources to the program, instead of using the built in version-info feature.
Your question seems to be fundamentally a matter of preventing the user from modifying (easily) the version number once you have determined it.
So my suggestion is that you encrypt the version number and you use the encrypted version, instead of the version in the VersionInfo structure.
I have used DCPCRYPT for things like this. But if you hope to be hacker-proof let me just say this; Anything you can do, hackers can undo. If you want to be more secure, you will also need to tamper proof your whole application. There are commercial tamper proofing solutions but none work fabulously out of the box with Delphi.

File Version Vs. Product Version

In the Delphi Project Properties dialog, there are settings for the "Product Version" and the "File Version". Can anyone explain the philosophical differences between the two?
The Product Version will be the version number of your whole application.
The File Version will be the version number of this component.
The two are usually in sync, but don't have to be. It would depend upon how modular your application was.
So for example you might have an application that's at version 2.3.4.0 (say), but one file reader component that's at version 5.6.7.0 as it was inherited from a different application and another at version 1.2.0.0 as it's a more recent addition.
Additionally, some components might not change between releases so theoretically they should remain at their original file version.
However, as this might well cause confusion (not least with the developer) about which file goes with which version of the product these numbers are often kept in sync.
Not all the files are to be changed when the product version changes.
E.g. you've written a dll implementing the core functionality that remains unchanged during following product version changes.
Product version is the version of the product the executable is a part of, like Firedox 3.5.2 - all files in the product should have the same version (for a given version, obviously). The file version is normally the version of the specific file, like the firefox executable, for example, without respect to the product. This doesn't seem to get used much.
In contrast to the file version the product version is not necessarily numerical. E.g. we use the pre-build scripts to set it to the current date. This way, we can easily check when an executable was built.

Delphi app calling cobol app -> error

We need to get data out of an older accounting system. We have received a dll that gives us access to the data we need. It includes a type library that we have imported.
If we run our test application from the same directory as the accounting system, everything works fine. If we try to run our application from a different directory, we get the following error:
Dynamically Bound RTS
Runtime DLL 'OOPS', version 3.1, entry point oops
not recorded in registry, not found or incompatible with requirements
of dynamically bound COBOL program. Dynamic binding of RTS requires:
Runtime DLL 'OOLSM', at least Version 3.1
Can anybody provide some helpful information on this?
Are we supposed to have some kind of cobol runtime in our directory? Or in the path? Or registered in the registry?
Thanks,
-Vegar
Updates:
Setting the system %path% to include the path to the accounting system seems to do the trick. Including it as a user variable did not have the same effect for some reason.
What Cobol are you using?
I had done this for year with Microfocus NetExpress 3.1, and all works just fine.
I write COBOL DLL to access COBOL data files, and also write Delphi DLL to add new features to old COBOL systens.
And yes, I use to set the runtime path, that is environment variable called COBDIR, there are others,but usually %PATH% and %COBDIR%is enough.
If you give more detais about what COBOL compiler are you using, and how is the dll interface that you are calling, will me ore easy to help you.
And maybe "Dependence Walker" can help you to identify what run time files are missing, if it is.
http://www.dependencywalker.com/
If it works from the accounting app's directory, but not a different one, the first thing I'd try is adding that directory to your path.
Unless it is already loaded into memory, Windows looks for DLL's that a program is requesting in every location listed in its PATH environment variable, and also in the directory the application is located within.

Resources