Java class version

Asked

Viewed 106 times

2

I wonder if in java I can specify a tag, or manifest, or something like that for a class or library and be able to query it within the Java code itself
guy :

@version 2.6.5
Class Pessoa {
...
}

and there in another part of the code

if (Class.getVersion(Pessoa) < 2.7)
{
   mensage.Aviso("Biblioteca de Pessoas em uma versão antiga. Atualize-o");
}

1 answer

1

Hello,

I don’t know anything that answers what you want and I can’t see a use for it either. The question is do you really need it? If you want to convert your class you can use git, Mercurial or svn. In addition, what you can do is check from a . class which minor and major version of Java your class was compiled into.

java -verbose MyClass

But if you still want something like what you posted, you can create an Annotation yourself and make a logic.

  • need this for automatic library updates if the version is lower than the one in FTP would be updated

  • there is how I create my own tags, right? I think I will create to implement this functionality. I wanted something ready.... but as there is no... =/

  • See, the way you want it, I don’t know anything ready. But if you need this to control library versions, why not use Maven for it? You use or know?

  • use only to resolve dependencies, control version had not seen yet

  • Then you can use it for that purpose too. You can define within the <dependencyManagement></dependencyManagement> (pom.xml) tag and specify the version of each lib.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.