10 Replies Latest reply on Jun 23, 2017 8:56 PM by Gary Graham-Oracle

    sqlcl - Error: Could not find or load main class

    Bazza

      windows 7

      downloaded java 1.8 jre 32/64bit

      1.8 jdk installed as well (64bit)

      unzipped sqlcl 4.2.0.17.097.0719

       

      sql.bat works, sql.exe does not.

       

      the error flashed up too quick, so ran it from dos:

       

      C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin>dir

      Volume in drive C is Local Disk

      Volume Serial Number is D83E-EB58

       

      Directory of C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin

       

      19/04/2017  13:56    <DIR>          .

      19/04/2017  13:56    <DIR>          ..

      19/04/2017  13:56            13,333 sql

      19/04/2017  13:56             2,585 sql.bat

      19/04/2017  13:56           570,428 sql.exe

                     3 File(s)        586,346 bytes

                     2 Dir(s)  29,178,138,624 bytes free

       

      C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin>sql.exe

      Error: Could not find or load main class <odd server name.domain;>

       

      I have tried setting a java_home in environment variables, putting sqlcl in the path but still wind up with the same error.

       

      any ideas? I know a similar issue was a bug but release notes states that was fixed in this iteration

       

      It isn't a major issue, as the sql.bat works but it is annoying me...

        • 1. Re: sqlcl - Error: Could not find or load main class
          Gary Graham-Oracle

          Your case matches neither of the fixed bugs that have been logged for "Could not find or load main class" for SQLcl over the past couple years.

           

          Perhaps Barry's comment on a conflict classpath setting may be relevant... Error: Could not find or load main class *.

          • 2. Re: sqlcl - Error: Could not find or load main class
            Gaz in Oz

            You need to check/setup some environment variables.

            Try setting up the jre/bin and jdk/bin in your %PATH%

            How else will dos know where java "lives"?...

            While we're on about %PATH% how about making life easier for yourself and add

            C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin

            too.

            then you can

            c:\> sql

            • 3. Re: sqlcl - Error: Could not find or load main class
              Bazza

              Thank you for the responses. I had seen the thread reference as its exactly what I am seeing, and I have tried adding java and sqlcl to path:

               

              Microsoft Windows [Version 6.1.7601]

              Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

               

              c:\>cd C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin

               

              C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin>echo %PATH%

              C:\Program Files\Java\jre1.8.0_131\bin;C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\b

              in;C:\ProgramData\Oracle\Java\javapath;

              ....

               

              C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin>sql

              Error: Could not find or load main class <odd server name>

               

              C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin>echo %CLASSPATH%

              %CLASSPATH%

               

              C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin>

               

              Any more ideas?

              • 4. Re: sqlcl - Error: Could not find or load main class
                Gary Graham-Oracle
                Error: Could not find or load main class <odd server name.domain;>

                What disturbs me about your error message (and the same happened in the case of Error: Could not find or load main class *.) is the appearance of a strange url in place of an expected class name.  Since no one else has reported this in SQLcl 4.2.0.17.097.0719, barring some entirely new bug, I suppose something could be corrupt in your environment.  I cannot find anything via web search that discusses references to server.domain urls in such messages.

                 

                Here is an odd case where (entirely unrelated!) a SQL Developer issue got resolved by rebuilding the user's Windows Profile.  You might want to try looking into whether or not something like that can help you...

                Re: Creating a 'new DB connection' hangs (SQL Developer  4.1.5,  4.2.0)   

                 

                Alternately, you could check whether anything else in the environment could be misleading SQLcl ...

                1. Any Java classpath settings in your Windows registry (not .classpath file extensions, of course)

                2. An environment variable setting called JAVA_TOOL_OPTIONS (probably not likely, but Oracle / Java will use it)

                3. An environment variable setting called JAVA_OPTS (even less likely, as Oracle / Java should not use it)

                 

                Best regards,

                Gary

                SQL Developer Team

                1 person found this helpful
                • 5. Re: sqlcl - Error: Could not find or load main class

                  The sql.bat file runs java and the class oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.

                   

                  What exactly does 'sql.exe' do? Any documentation anywhere?

                   

                  OP isn't showing any CLASSPATH setting and you can execute sql.exe without one and it works fine.

                  • 6. Re: sqlcl - Error: Could not find or load main class
                    Gary Graham-Oracle

                    Yes, the OP's issue is a bit mysterious since we just use launch4j (Launch4j - Cross-platform Java executable wrapper) to build the exe.

                     

                    In the build.xml we configure all the expected things like the mainClass, classPath (the stuff copied into sqlcl\lib), jre minVersion, the stuff in the startup banner (product, version, copyright, etc), and various parameters passed through to Java.  Possibly something in the OP's Windows registry having to do with proxy settings could be the cause...

                    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\...

                    We grab ProxyEnable, ProxyServer, ProxyOverride, and AutoConfigURL

                    • 7. Re: sqlcl - Error: Could not find or load main class

                      Hmmm - not sure I even want to get into the whole 'enabling proxies in the registry' stuff.

                       

                      I suggest OP:

                       

                      1. submit a bug report

                      2. provide Oracle the results of 'sql.exe -verbose'.

                      3. provide similar results with the utililty configured for 'debug- if that is possible

                      4. search their registry for that 'url' that wasn't posted - that wasn't created out of thin air so it had to come from somewhere.

                      5. test using 'admin' privileges (run as administrator) to eliminate as many privilege issues as possible.

                       

                      In my test that shows

                       

                      1. the checking for any banner file (but only for the user, not the machine/ALL users). It also shows a 'FileNotFoundException when it can't find 'banner'ser'. That suggests to be a 'bug' since, IMHO, it should NOT be an exception if an optional file is missing - the code should trap that.

                      SQLcl: Release 4.2.0 Production on Sat Jun 03 08:46:00 2017

                       

                      Copyright (c) 1982, 2017, Oracle.  All rights reserved.

                       

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.versions.CheckForUpdates getBanner

                      INFO: C:\Users\Administrator\AppData\Roaming\sqlcl\banner.ser (The system cannot find the file specified) at java.io.Fil

                      eInputStream.open0(Native Method)

                      java.io.FileNotFoundException: C:\Users\Administrator\AppData\Roaming\sqlcl\banner.ser (The system cannot find the file

                      specified)

                              at java.io.FileInputStream.open0(Native Method)

                              at java.io.FileInputStream.open(Unknown Source)

                              at java.io.FileInputStream.<init>(Unknown Source)

                              at java.io.FileInputStream.<init>(Unknown Source)

                              at oracle.dbtools.versions.CheckForUpdates.getBanner(CheckForUpdates.java:429)

                              at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.handleUpdates(SqlCli.java:509)

                              at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.main(SqlCli.java:465)

                       

                      2. numerous checks for an Oracle home - these check the registry but no mention of checks of environment variables

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:SOFTWARE\ORACLE\KEY_OraDB12Home2

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:SOFTWARE\ORACLE\KEY_OraDB12Home2

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.utils.TNSHelper getOracleHome

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.newscriptrunner.SQLPlusProviderForSQLPATH getOracleEnv

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.newscriptrunner.SQLPlusProviderForSQLPATH getOracleEnv

                      INFO: Checking found key for ORACLE_HOME:SOFTWARE\ORACLE\KEY_OraDB12Home2

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.newscriptrunner.SQLPlusProviderForSQLPATH getOracleEnv

                      INFO: Checking found ORACLE_HOME:I:\Oracle12201\app\Administrator\product\12.2.0\dbhome_1\dbs

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.newscriptrunner.SQLPlusProviderForSQLPATH getOracleEnv

                      INFO: Checking found key for ORACLE_HOME:null

                      Jun 03, 2017 8:46:00 AM oracle.dbtools.raptor.newscriptrunner.SQLPlusProviderForSQLPATH getOracleEnv

                      INFO: Checking found key for ORACLE_HOME:null

                      Seems like a lot of multiple checking to me but the actual mechanics aren't really for public consumption. Except to say if 'verbose' is going expose a check there should be enough info to differentiate between seemingly identical messages.

                       

                      I would note that there is no 'path' or 'classpath' info reported.

                      1 person found this helpful
                      • 8. Re: sqlcl - Error: Could not find or load main class
                        3068389

                        If you check the CYGWIN environment variable $CYGWIN %CYGWIN% it should be reset in the sql (bash file) for it to functions.

                        • 9. Re: sqlcl - Error: Could not find or load main class
                          Bazza

                          Sorry  been away.

                           

                          Anyhow -

                          1. Any Java classpath settings in your Windows registry (not .classpath file extensions, of course)

                          2. An environment variable setting called JAVA_TOOL_OPTIONS (probably not likely, but Oracle / Java will use it)

                          3. An environment variable setting called JAVA_OPTS (even less likely, as Oracle / Java should not use it)

                          1 - not that I could find

                          2 - nope

                          3 - nope

                           

                          HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\...

                          We grab ProxyEnable, ProxyServer, ProxyOverride, and AutoConfigURL

                          The server that I get listed is in the list of servers for ProxyOverride...and that is the only place it is in the registry

                           

                          Also tried the following but further output (as administrator):

                           

                          C:\sqlcl-4.2.0.17.097.0719-no-jre\sqlcl\bin>sql.exe -verbose

                          Error: Could not find or load main class <server.domain>;

                          • 10. Re: sqlcl - Error: Could not find or load main class
                            Gary Graham-Oracle

                            There is no reference to ProxyOverride in the SQL Developer code beyond a reference to it in the ant build.xml rule for sql.exe, which instructs the Launch4j executable wrapper to get it from the Windows registry.

                             

                            In my personal Windows 7 test environment, with no issues starting SQLcl via sql.exe,  I have...

                            1. No registry entries set for ProxyServer or ProxyOverride.

                            2. ProxyEnable set to 0 (disabled).

                            3. AutoConfigURL is some URL that Oracle IT provides to us for internal use.

                            So it seems likely your issue relates to how Launch4j is interacting with your registry settings. It is uncertain whether the issue might be the registry settings themselves, or perhaps the version of Launch4j we use.  Doing a web search on "Launch4j proxy settings" I get hits like ...

                            https://github.com/processing/processing/issues/3588

                            https://github.com/processing/processing/issues/3891

                             

                            Edit:  This is a bit complex to research as it goes beyond just the SQL Developer application Java code.  Best to log a Service Request with My Oracle Support (MOS).