Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 448
  • Last Modified:

compile SSL client socket program on solaris

Hi,

I am compiling the SSL Socket client program on sun solaris 5.7.
i have installed j2se 1.4 version on solaris sparc 64 bit.

when i am compiling the .java file, it is giving the following error:

in /usr/j2se/jre/lib/jsse.jar(javax/net/ssl/SSLSocket.class).  wrong version: 46, expected 45

please help
0
kulsmadya
Asked:
kulsmadya
  • 11
  • 11
1 Solution
 
girionisCommented:
 Hmmm. TO be honest withyou I do not know what the aboveerror message means. Just a suggestion. Are you using the latest JSSE API? If not try to upgrade and recompile.

  Hope it helps.
0
 
kulsmadyaAuthor Commented:
i have installed the j2sdk 1.4.0 on sun solaris 5.7 sparc 64 bit.

my java-home is /usr/j2se

0
 
OviCommented:
javax/net/ssl/SSLSocket.class class was compiled with an improper (older/newer) version of javac
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
kulsmadyaAuthor Commented:
when i compile
SSLSocketClient.java a sample program given on java.sun.com site, the error which i get is as follows:

$ javac SSLSocketClient.java
error: Invalid class file format in /usr/j2se/jre/lib/jsse.jar(javax/net/ssl/SSLSocketFactory.class).  wrong version: 46, expected 45
SSLSocketClient.java:55: Class javax.net.ssl.SSLSocketFactory not found in type declaration.
            SSLSocketFactory factory =
            ^
SSLSocketClient.java:56: Class javax.net.ssl.SSLSocketFactory not found in type declaration.
                (SSLSocketFactory)SSLSocketFactory.getDefault();
                 ^
SSLSocketClient.java:56: Class javax.net.ssl.SSLSocketFactory not found in type declaration.
                (SSLSocketFactory)SSLSocketFactory.getDefault();
                                  ^
SSLSocketClient.java:56: Undefined variable or class name: SSLSocketFactory
                (SSLSocketFactory)SSLSocketFactory.getDefault();
                                  ^
error: Invalid class file format in /usr/j2se/jre/lib/jsse.jar(javax/net/ssl/SSLSocket.class).  wrong version: 46, expected 45
SSLSocketClient.java:57: Class javax.net.ssl.SSLSocket not found in type declaration.
            SSLSocket socket =
            ^
SSLSocketClient.java:58: Class javax.net.ssl.SSLSocket not found in type declaration.
                (SSLSocket)factory.createSocket("www.verisign.com", 443);
                 ^
8 errors
0
 
girionisCommented:
 If you are using JDK1.4 then you are using the latest version of JSSE, since it is an integral part of the latest JDK. The errors you are getting mean that your VM cannot find the classes you are trying to use. Are you sure that you have the jsse.jar in your classpath? Try to do:

$ javac -cp /usr/j2se/jre/lib/jsse.jar SSLSocketClient.java

  and see what happens.

  Hope it helps.
0
 
girionisCommented:
 If this does not work try to replace the jsse.jar with an older jsse.jar, it coudl be usign an older version (as Ovi suggested first).
0
 
kulsmadyaAuthor Commented:
i tried
javac -cp /usr/j2se/jre/lib/jsse.jar SSLSocketClient.java

but its giving the error:
javac: invalid flag: -cp
Usage: javac <options> <source files>
0
 
kulsmadyaAuthor Commented:
i tried
javac -cp /usr/j2se/jre/lib/jsse.jar SSLSocketClient.java

but its giving the error:
javac: invalid flag: -cp
Usage: javac <options> <source files>
0
 
kulsmadyaAuthor Commented:
my jsse.jar is in the classpath...

where can i find the older version of the jsse.jar, which will help me in compiling the java class.
0
 
girionisCommented:
0
 
girionisCommented:
 Oh, by the way if the -cp does not work you might want to use the -classpath instead.
0
 
kulsmadyaAuthor Commented:
i have downloaded the older version of the jsse & i have placed jsse.jar, jcert.jar & jnet.jar in my classpath.
Now my program has compiled.
0
 
girionisCommented:
 So as Ovi suggested first the classes were compiled with an older version. I think you should award most of the points to Ovi since he gave me the idea to suggest you get an older version of the JSSE API.
0
 
kulsmadyaAuthor Commented:
now i am facing a following error when i run the java program:

java.lang.NoClassDefFoundError: java/security/PrivilegedAction
        at javax.net.ssl.SSLSocketFactory.a(Compiled Code)
        at javax.net.ssl.SSLSocketFactory.getDefault(Compiled Code)
        at SSLSocketClient.main(Compiled Code)
0
 
girionisCommented:
 It is obviously missing the class. Find out in which jar file this class resides and put it in your classpath.

  Hope it helps.
0
 
kulsmadyaAuthor Commented:
its in the rt.jar but where should i get the older version of rt.jar? as i have the latest version of it. & if i place that jar file in the classpath, it is giving the error that, class is having newer version, requiered older version.
0
 
girionisCommented:
 Hm... rt.jar is the runtime java archive for the JRE. You will need to use an older JDK (maybe 1.3) if you want to have an older version of the rt.jar.

  The whole problem started since you tried an older version of the SSLSocketClient. Maybe it would be easier to just try a newer example that uses the newer rt.jar and the newer JSSE API.

  Igf you still want to use an older rt.jar then you will need to get the earlier version of the JDK.

  Hope it helps.
0
 
kulsmadyaAuthor Commented:
I have downloaded the j2sdk1.4.0 on my windows 2000 machine. & when i run my program there, i am not facing any problem.

but when i had installed the j2sdk1.4.0 on the sun box & compile & run my program, i faced the above problem. Thats why i have reverted to the older version of jsse.

So, what could be the problem on Sun machine?? why it is not taking the j2sdk1.4.0? any ideas?
0
 
girionisCommented:
 Both machines have a different architecture and you cannot be sure what is going on on the underlying system. What I sufggest you to do is to compile and run your programmes on Windows and then take the very same class file and try to run them on Solaris (without recompiling). See what happens.
0
 
kulsmadyaAuthor Commented:
i want to award the points to 2 experts what should i do??
0
 
girionisCommented:
 Hmmm... I realy do not know. I suggest you ask a mderator.

  Did you finally solve the problem?
0
 
kulsmadyaAuthor Commented:
ya,
i solved the problem.

i have installed the jsse1.0.2 on sun box. gave all 3 jar files path in classpath.
installed j2sdk1.3.1.03.
added the code for dynamically load the ssl provider(it has given in the installation instructions of the jsse1.0.2).

then compiled the java file. its working.
:)
0
 
girionisCommented:
 We are glad we helped :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 11
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now