Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

bad major version at offset=6  RSS feed

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have googled before posting this question as I could not solve my issue.
I am learning webservice and have created a WAR file in Java 6 and trying to install it in IBM Websphere which is also Java 6.
I get below error during deployment. Please help me understand this error.



 
Saloon Keeper
Posts: 4860
117
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leaving aside the problems with running a JVM that's years out of date (be aware that extended support ends in a few months), it seems that the problem is with the class com/devguerrilla/quickstart/cxf/countrylookup/CountryLookupServiceImpl. What Java version was used to compile it? If you don't know, examine bytes 5 and 6 of the class file; for more information see Java class file.
 
Rancher
Posts: 3276
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the contents of the class file named in the error message.  What is the contents of bytes 6 and 7?  For Java version 6 it should be 0x00 0x32
 
Tim Moores
Saloon Keeper
Posts: 4860
117
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:examine bytes 5 and 6 of the class file


Oops, that should read bytes 7 and 8. Norm is using byte offsets from the first byte, a (IMO) rather confusing way to count bytes that numbers the first byte as being 0.
 
Norm Radder
Rancher
Posts: 3276
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen this type of problem when a non class file has mistakenly be renamed with a .class extension and included in a jar file. Of course the class file checker will see a bad version code.
 
murali jackson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

Sorry for very late reply. I was out for a week . I could not check the post.
Thanks very much for your suggestions, I will check and update here shortly.
 
murali jackson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:

Tim Moores wrote:examine bytes 5 and 6 of the class file


Oops, that should read bytes 7 and 8. Norm is using byte offsets from the first byte, a (IMO) rather confusing way to count bytes that numbers the first byte as being 0.



Hi Norm/ Tim,

Can you please tell me how i can view the contents of a class file.
I just tried opening it in a text pad and i got this strange contents in the file. I could not even copy and put it here as it says null characters.
If i try de-compile, then I will get the java class only right ? I dont know how to check the data which you have advised. Please advise.
 
Norm Radder
Rancher
Posts: 3276
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if you can find a hex editor to look at the contents of the .class file as hex bytes.
 
murali jackson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:See if you can find a hex editor to look at the contents of the .class file as hex bytes.



Thanks Norm !!!
I have downloaded Hxd and opened the file.
Below is the content I see on the first line.



In bytes 6 and 7 , its 00 and 32, so it looks like it has been compiled in Java 6 .
 
Bartender
Posts: 2070
276
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

murali jackson wrote:Can you please tell me how i can view the contents of a class file.


The easiest way might be to use javap  - it will show major and minor version numbers.
 
Norm Radder
Rancher
Posts: 3276
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are a few lines of code that read and display the first 40 bytes of a file.  Change it to read your class file instead of TestCode24

The version number at byte 7 0x34 = 52
 
murali jackson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Norm,

I have ran the code using my class file and below is the output im getting.



I am still confused on how to decipher this. Please advise.

Hi Ron,

I tried that JavaP command after putting my classfile in the same path. But im getting below error.


C:\apache

C:\apache>javap -v CountryLookupServiceImpl.class classfile com.devguerrilla.qui
ckstart.cxf.countrylookup.CountryLookupServiceImpl
ERROR:Could not find CountryLookupServiceImpl.class


 
Norm Radder
Rancher
Posts: 3276
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ERROR:Could not find CountryLookupServiceImpl.class 


Where is the CountryLookupServiceImpl.class file located?
The javap program can not find it.
 
murali jackson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:

ERROR:Could not find CountryLookupServiceImpl.class 


Where is the CountryLookupServiceImpl.class file located?
The javap program can not find it.



Hi Norm,

The CountryLookupServiceImpl.class file is located in the below folder.
C:\apache

I ran the command also from the same folder.

I have used your program and gave the contents of the output earlier, could you please tell me whether that helped in showing where the problem is.

 
Norm Radder
Rancher
Posts: 3276
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you use the dir command to list all the files in the folder
and then use the javap command that shows the file not found message.

Copy the contents of the command prompt window and paste it here.
 
murali jackson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:Can you use the dir command to list all the files in the folder
and then use the javap command that shows the file not found message.

Copy the contents of the command prompt window and paste it here.




Please find the details below

 
Norm Radder
Rancher
Posts: 3276
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is all this after the name of the class file?


Classfile com.devguerrilla.qui
ckstart.cxf.countrylookup.CountryLookupServiceImpl.class



Did you try:
javap -v CountryLookupServiceImpl.class
 
murali jackson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Norm Radder wrote:What is all this after the name of the class file?


Classfile com.devguerrilla.qui
ckstart.cxf.countrylookup.CountryLookupServiceImpl.class



Did you try:
javap -v CountryLookupServiceImpl.class



Yeah , I tried. It shows the same error.

 
Norm Radder
Rancher
Posts: 3276
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what the problem is.  Here is an example where I renamed the class file by adding XXX so it did not represent what was in the file and it worked:


javap -v AppletCommMainXXX.class
Classfile /D:/JavaDevelopment/Testing/Applet_Tests/ForTest/AppletCommMainXXX.class
  Last modified Oct 9, 2005; size 2386 bytes
  MD5 checksum ad8842a92854a5204a7b22ce8ee7e928
  Compiled from "AppletCommMain.java"
public class Testing.AppletCommMain extends java.applet.Applet implements java.awt.event.ItemListener
  minor version: 3
  major version: 45




Another test with a file that was not a class file:



D:\BatchFiles>cmd.exe /K cd "D:\JavaDevelopment\Testing\Applet_Tests\ForTest"

D:\JavaDevelopment\Testing\Applet_Tests\ForTest>dir
Volume in drive D is Work
Volume Serial Number is 76C0-3722

Directory of D:\JavaDevelopment\Testing\Applet_Tests\ForTest

08/15/2018  05:26 PM    <DIR>          .
08/15/2018  05:26 PM    <DIR>          ..
10/09/2005  11:39 AM             2,386 AppletCommMainXXX.class
08/15/2018  05:26 PM            21,971 JavapConsole.txt
               2 File(s)         24,357 bytes
               2 Dir(s)  15,458,840,576 bytes free

D:\JavaDevelopment\Testing\Applet_Tests\ForTest>javap -v JavapConsole.txt
Error: class not found: JavapConsole.txt                      <<<<<<<<<< NOTE error message

D:\JavaDevelopment\Testing\Applet_Tests\ForTest>dir JavapConsole.txt
Volume in drive D is Work
Volume Serial Number is 76C0-3722

Directory of D:\JavaDevelopment\Testing\Applet_Tests\ForTest

08/15/2018  05:26 PM            21,971 JavapConsole.txt
               1 File(s)         21,971 bytes
               0 Dir(s)  15,458,840,576 bytes free

D:\JavaDevelopment\Testing\Applet_Tests\ForTest>

 
Ron McLeod
Bartender
Posts: 2070
276
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try without including the .class suffix:
    javap -v CountryLookupServiceImpl

javap expects classnames, not filenames (although the version of javap that I used was forgiving and didn't complain) - my fault for incorrectly putting a filename in the example.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!