Link to home
Start Free TrialLog in
Avatar of Tacobell777
Tacobell777

asked on

cannot resolve symbol

I can't figure out what is causing this?

C:\Temp>javac SSLTransportLayer.java
SSLTransportLayer.java:62: cannot resolve symbol
symbol  : method getEnabledProtocols  ()
location: class javax.net.ssl.SSLSocket
     String[] protocolArray = socket.getEnabledProtocols();
                                    ^


Code:

import javax.net.ssl.*;
import java.io.*;

public class SSLTransportLayer  {

 public static void main(String[] args) {
   String host = "edge.asic.gov.au";
   int    port = 5608;

   SSLSocketFactory factory;
   SSLSocket        socket;
   String           hostOutput;
   BufferedReader   br;
   String[] cipherSuite = { "SSL_RSA_WITH_RC4_128_MD5"
            ,"SSL_RSA_WITH_RC4_128_SHA"
         ,"TLS_RSA_WITH_AES_128_CBC_SHA"
         ,"TLS_DHE_RSA_WITH_AES_128_CBC_SHA"
         ,"TLS_DHE_DSS_WITH_AES_128_CBC_SHA"
         ,"SSL_RSA_WITH_3DES_EDE_CBC_SHA"
         ,"SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA"
         ,"SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"
         ,"SSL_RSA_WITH_DES_CBC_SHA"
         ,"SSL_DHE_RSA_WITH_DES_CBC_SHA"
         ,"SSL_DHE_DSS_WITH_DES_CBC_SHA"
         ,"SSL_RSA_EXPORT_WITH_RC4_40_MD5"
         ,"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA"
         ,"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA"
         ,"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"
         ,"SSL_RSA_WITH_NULL_MD5"
         ,"SSL_RSA_WITH_NULL_SHA"
         ,"SSL_DH_anon_WITH_RC4_128_MD5"
         ,"TLS_DH_anon_WITH_AES_128_CBC_SHA"
         ,"SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"
         ,"SSL_DH_anon_WITH_DES_CBC_SHA"
         ,"SSL_DH_anon_EXPORT_WITH_RC4_40_MD5"
         ,"SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA" };
   
   /*{ "SSL_DH_anon_WITH_RC4_128_MD5"
                          , "SSL_DH_anon_WITH_RC4_128_MD5"
                          , "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"
                          , "SSL_DH_anon_WITH_DES_CBC_SHA"
                          , "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5"
                          , "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA" };*/


   
   try {
     factory = ( SSLSocketFactory ) SSLSocketFactory.getDefault();
     socket  = ( SSLSocket ) factory.createSocket( host, port );
     // Lets see whats supported
     String[] suiteArray = socket.getSupportedCipherSuites();
     for ( int i = 0; i < suiteArray.length; i++ )
     {
           System.out.println( "Supported cipher suites " +  suiteArray[ i ] );
     }
     
     System.out.println( "Enabled session creation " +  socket.getEnableSessionCreation() );
     System.out.println( "Use client mode " +  socket.getUseClientMode() );
//     System.out.println( "Want client mode " +  socket.getWantClientAuth() );
     System.out.println( "Needs client authentication " +  socket.getNeedClientAuth() );
     
     String[] protocolArray = socket.getEnabledProtocols();
     for ( int i = 0; i < protocolArray.length; i++ )
     {
           System.out.println( "Enabled protocols " +  protocolArray[ i ] );
     }
         
     socket.setEnabledCipherSuites(cipherSuite);

     System.out.println("Secure socket made");
     br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
     hostOutput = br.readLine();
     System.out.println(host + " responds with: " + hostOutput);

   } catch (Exception e) {
     System.out.println("Error " + e.getMessage());
   };
 }
}
Avatar of InteractiveMind
InteractiveMind
Flag of United Kingdom of Great Britain and Northern Ireland image

SSLSocket#getSupportedProtocols() does not exist, you need to replace that with:

String[] protocolArray = socket.getSupportedProtocols();
Sorry, this:

 "SSLSocket#getSupportedProtocols() does not exist"

should be:

 "SSLSocket#getEnabledProtocols() does not exist"
Avatar of CEHJ
Make sure you haven't got your own home-brewed SSLSocket in the classpath (as opposed to javax.net.ssl.SSLSocket, which is what you intend)
Avatar of Tacobell777
Tacobell777

ASKER

InteractiveMind ??? Isn't that what I have got?

CEHJ I'm pretty sure no one replaced it as I installed it a couple of weeks ago.
Try compiling thus and see if it makes any difference:


javac -classpath . SSLTransportLayer.java
C:\Temp>javac -classpath C:\j2sdk1.4.2_05\bin SSLTransportLayer.java
SSLTransportLayer.java:1: package javax.net.ssl does not exist
import javax.net.ssl.*;
^
SSLTransportLayer.java:10: cannot resolve symbol
symbol  : class SSLSocketFactory
location: class SSLTransportLayer
   SSLSocketFactory factory;
   ^
>>package javax.net.ssl does not exist

What JDK version are you using?

j2sdk1.4.2_05
There's something wrong. javax.net.ssl *does* exist in 1.4. What do you get from


java -version

?
Sorry that should have been

javac -version
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

javac -version is not a valid command line..

I now get the same error with other classes as well, but they compile well on
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)
>>javac -version is not a valid command line..

No - it isn't on some versions. Javac will run against the first javac.exe in %PATH%. What would that be?

echo %PATH%
do you still need that version, does the verion number I gave above not give you enough info?
>>does the verion number I gave above not give you enough info?

It gives me the version of java, not javac, and the latter is needed here (they can be different)
Here is the output, sorry it took so long.

C:\CFusionMX7\verity\k2\_nti40\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Sys
tem32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\
Microsoft SQL Server\80\Tools\BINN;C:\Sun\AppServer\jdk\bin;c:\Program Files\Mic
rosoft SQL Server\90\Tools\binn\;C:\PROGRA~1\AMPC\bin;C:\PROGRA~1\AMPC\cygwin\bi
n;C:\Sun\AppServer\bin
This is almost certainly the version of javac you're compiling with

C:\Sun\AppServer\jdk\bin\javac.exe

and i would not be suprised if it is < 1.4. Failure to compile the following will prove that it is:


class LessThanFour {
      void acidTest() {
            "x".replaceAll("", "");
      }
}
this is what I get
C:\Temp>javac LessThanFour.java
LessThanFour.java:3: cannot resolve symbol
symbol  : method replaceAll  (java.lang.String,java.lang.String)
location: class java.lang.String
          "x".replaceAll("", "");
          ^
1 error

So can you tell me what you think is wrong and how to fix it?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I must be confused I thought I did that, isn't the JDK included in Java(TM) 2 Runtime Environment

Or the two different if so can you give me a little run down?
I'm still a newbie to this all.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please *do* give IM some points for that info ;-)
thanks guys
:-)
hehe - thank you both ;)