Solved

compile SSL client socket program on solaris

Posted on 2002-05-21
23
441 Views
Last Modified: 2013-12-05
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
Comment
Question by:kulsmadya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 11
23 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 7023833
 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
 

Author Comment

by:kulsmadya
ID: 7023881
i have installed the j2sdk 1.4.0 on sun solaris 5.7 sparc 64 bit.

my java-home is /usr/j2se

0
 
LVL 9

Expert Comment

by:Ovi
ID: 7023888
javax/net/ssl/SSLSocket.class class was compiled with an improper (older/newer) version of javac
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:kulsmadya
ID: 7023889
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
 
LVL 35

Expert Comment

by:girionis
ID: 7023974
 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
 
LVL 35

Expert Comment

by:girionis
ID: 7024008
 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
 

Author Comment

by:kulsmadya
ID: 7024354
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
 

Author Comment

by:kulsmadya
ID: 7024358
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
 

Author Comment

by:kulsmadya
ID: 7024366
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
 
LVL 35

Expert Comment

by:girionis
ID: 7024391
0
 
LVL 35

Expert Comment

by:girionis
ID: 7024394
 Oh, by the way if the -cp does not work you might want to use the -classpath instead.
0
 

Author Comment

by:kulsmadya
ID: 7024482
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
 
LVL 35

Expert Comment

by:girionis
ID: 7024498
 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
 

Author Comment

by:kulsmadya
ID: 7024585
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
 
LVL 35

Expert Comment

by:girionis
ID: 7024634
 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
 

Author Comment

by:kulsmadya
ID: 7024672
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
 
LVL 35

Expert Comment

by:girionis
ID: 7025118
 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
 

Author Comment

by:kulsmadya
ID: 7025870
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
 
LVL 35

Expert Comment

by:girionis
ID: 7026477
 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
 

Author Comment

by:kulsmadya
ID: 7028802
i want to award the points to 2 experts what should i do??
0
 
LVL 35

Expert Comment

by:girionis
ID: 7029158
 Hmmm... I realy do not know. I suggest you ask a mderator.

  Did you finally solve the problem?
0
 

Author Comment

by:kulsmadya
ID: 7029269
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
 
LVL 35

Accepted Solution

by:
girionis earned 300 total points
ID: 7029287
 We are glad we helped :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question