Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Could not find class dev.SASJavaExec #3

Open
77QingLiu opened this issue Sep 29, 2017 · 16 comments
Open

Could not find class dev.SASJavaExec #3

77QingLiu opened this issue Sep 29, 2017 · 16 comments

Comments

@77QingLiu
Copy link

Hello,

I use the following sas code to run python program,

data _null_;
  length rtn_val 8;
  *** Python program takes working directory as first argument;
  python_pgm = "&WORK_DIR.\digitsdata_svm.py";
  python_arg1 = "&WORK_DIR";      
  python_call = cat('"', trim(python_pgm), '" "', trim(python_arg1), '"'); 

  declare javaobj j("dev.SASJavaExec", "python", python_call); 
  j.callIntMethod("executeProcess", rtn_val);
run;

but I got a error

Could not find class dev.SASJavaExec

I pretty sure I follow your instruction, but still the SAS could not find the dev.SASJavaExec class.

image

@FriedEgg
Copy link

The most logically explanation is that you did not properly configure your CLASSPATH environment variable. Example to validate CLASSPATH here

You can set this in your SAS session by using the SET Option before you data step.

options set=classpath "C:\Path\to\SASJavaExec.class";

@77QingLiu
Copy link
Author

Hi @FriedEgg ,
Thank you for your quick reponse.
I have double checked my CLASSPATH, and also pass the VALIDATE JAVA CLASSPATH SAS Program.
But still I got this error.

@77QingLiu
Copy link
Author

and I attached the following code for your reference.

  • My SAS Program:
options set=classpath "C:\Users\c244032\Documents\SAS_Base_OpenSrcIntegration\bin";


%let WORK_DIR = C:\Users\c244032\Documents\SAS_Base_OpenSrcIntegration;
data _null_;
  length rtn_val 8;
  *** Python program takes working directory as first argument;
  python_pgm = "&WORK_DIR.\digitsdata_svm.py";
  python_arg1 = "&WORK_DIR";      
  python_call = cat('"', trim(python_pgm), '" "', trim(python_arg1), '"'); 

  declare javaobj j("dev.SASJavaExec", "python", python_call); 
  j.callIntMethod("executeProcess", rtn_val);
run;
  • My SAS_Base_OpenSrcIntegration path:
    image

@FriedEgg
Copy link

FriedEgg commented Oct 1, 2017

Judging solely by the pictures you have posted, the compiled class files appear to be in a different location in the first post you made than in the second. There is still no reason to assume that the CLASSPATH not being set correctly is the item at fault here. Can you verify that in you second post, the bin directory "C:\Users\c244032\Documents\SAS_Base_OpenSrcIntegration\bin" contains the subfolder "dev" which subsequently contain the file "SASJavaExec.class"

Try running the following in SAS and see what it says:

proc javainfo all; run;

@77QingLiu
Copy link
Author

@FriedEgg , Sorry for the late response as I was in vacation in last week. and also thanks very much for your quick response.
I double checked my directory, and it does contain dev with SASJavaExec.class.
Also I run the

Proc javainfo all; runn;

it shows

38   proc javainfo all; run;

PFS_TEMPLATE = C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\qrpfstpt.xml
awt.toolkit = sun.awt.windows.WToolkit
file.encoding = GBK
file.encoding.pkg = sun.io
file.separator = \
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.awt.headless = false
java.awt.printerjob = sun.awt.windows.WPrinterJob
java.class.path = C:\PROGRA~1\SASHome\SASVER~1\eclipse\plugins\SASLAU~1.JAR
java.class.version = 51.0
java.endorsed.dirs = C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\endorsed
java.ext.dirs = C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\ext;C:\windows\Sun\Java\lib\ext
java.home = C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre
java.io.tmpdir = C:\Users\c244032\AppData\Local\Temp\
java.library.path = C:\Program
Files\SASHome\SASFoundation\9.4\core\sasext;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\W
indowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\C:\Users\c244032\Desktop\APP\SAS\Secure\ccme4;C:\Program Files\SASHome\Secure\ccme4;C:\Program Files\SASHome\x86\Secure\ccme4;C:\Program
Files\SASHome\SASFoundation\9.4\ets\sasexe;C:\TDM-GCC-64\bin;C:\Program
Files\nodejs\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;D:\APP\CTEX\UserData\miktex\bin;D:\APP\CTEX\MiKTeX\miktex\bin;D:\APP\CTEX\CTeX\ctex\bin;D:\APP\CTEX\CTeX\cct\bin;D:\APP\CTEX\CTeX\ty\bin;D:\APP\CTEX\Ghostscript\gs9.05\bin
;D:\APP\CTEX\GSview\gsview;D:\APP\CTEX\WinEdt;C:\Program Files\PuTTY\;C:\Users\c244032\Desktop\APP\SAS\x86\Secure\ccme4;D:\APP\Anaconda3;D:\APP\Anaconda3\Scripts;D:\APP\Anaconda3\Library\bin;C:\Program
Files\SASHome\SASFoundation\9.4\core\sasext;C:\Users\c244032\AppData\Local\Pandoc\;C:\Users\c244032\AppData\Local\rodeo\app-2.5.2\bin;C:\Program Files
(x86)\mingw-w64\mingw32\bin;C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\Users\c244032\AppData\Roaming\npm;D:\APP\MTax\miktex\bin\x64\;C:\Program Files\Java\jdk1.8.0_131\bin;.
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.7.0_76-b13
java.security.auth.login.config = C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.login.config
java.security.policy = C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.policy
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 1.7
java.system.class.loader = com.sas.app.AppClassLoader
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.7.0_76
java.vm.info = mixed mode
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 1.7
java.vm.vendor = Oracle Corporation
java.vm.version = 24.76-b04
line.separator = 

log4j.configuration = file:/C:/Program%20Files/SASHome/SASFoundation/9.4/tkjava/sasmisc/sas.log4j.properties
os.arch = amd64
os.name = Windows 7
os.version = 6.1
path.separator = ;
sas.app.class.path = C:\PROGRA~1\SASHome\SASVER~1\eclipse\plugins\tkjava.jar
sas.ext.config = C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.java.ext.config
sas.home = C:\Program Files\SASHome
sas.jre.libjvm = C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\bin\server\jvm.dll
sas.root = C:\Program Files\SASHome\SASFoundation\9.4
sas.tkjni =
sun.arch.data.model = 64
sun.awt.enableExtraMouseButtons = true
sun.boot.class.path =
C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\resources.jar;C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\rt.jar;C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\sunrsasign.jar;C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\jsse.jar;C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\jce.ja
r;C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\charsets.jar;C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\lib\jfr.jar;C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\classes
sun.boot.library.path = C:\PROGRA~1\SASHome\SASPRI~1\9.4\jre\bin
sun.cpu.endian = little
sun.cpu.isalist = amd64
sun.desktop = windows
sun.io.unicode.encoding = UnicodeLittle
sun.jnu.encoding = GBK
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.os.patch.level = Service Pack 1
tkj.app.launch.config = C:\PROGRA~1\SASHome\SASVER~1\picklist
user.country = CN
user.dir = C:\Users\c244032
user.home = C:\Users\c244032
user.language = zh
user.name = C244032
user.script =
user.timezone = Asia/Shanghai
user.variant =

NOTE: ¡°PROCEDURE JAVAINFO¡±ËùÓÃʱ¼ä£¨×Ü´¦Àíʱ¼ä£©:
      ʵ¼Êʱ¼ä          0.12 Ãë
      CPU ʱ¼ä          0.07 Ãë

@vishwath13
Copy link

@FriedEgg It is the same error that @77QingLiu faces which I am facing now. I have a doubt, in the document given for this: It has been specified that in the initial setup that Two Java classes: SASJavaExec.java and StreamManagerThread.java will get downloaded in the WORK_DIR which is not the case. Is that the problem ,that I am facing where the Error as "Could not find class dev.SASJavaExec"
pmml_error
pmml_error_2

@rmyneni
Copy link

rmyneni commented Apr 6, 2018

@vishwath13 The pdf needs to be updated i.e., you no longer need two files as the content of StreamManagerThread.java was merged into SASJavaExec.java, hence you only need the latter.

There is a note in the readme that I am copying below that might help. Which version of Java did you use to compile?

NOTE: This project was compiled with Oracle JDK 1.7.0_25. We highly recommend using Java 7 to compile the java files in this project. When class files generated by some versions of Java 8 are used, the Base SAS Java Object fails with the following error:
ERROR: Could not find class dev.SASJavaExec at line 35 column 20. Please ensure that the CLASSPATH is correct. ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase. java.lang.UnsupportedClassVersionError: dev/SASJavaExec : Unsupported major.minor version 52.0

@vishwath13
Copy link

vishwath13 commented Apr 9, 2018

@rmyneni Thank you so much. It is the same error except for the last line.
pmml_error_3

Where can I find the updated PDF Document and I tried using Oracle JDK 1.6.0_some version and later using 1.8.0_161. Should I specifically try with Java 7 version ? If so, Can you send me a link where I can download Java 7 version ? I was only able to get Java 8 versions available online.

@rmyneni
Copy link

rmyneni commented Apr 13, 2018

@vishwath13 The PDF is accurate except for the list of classes you need -- that is, you only need SASJavaExec.java file. We have not tested with Java 6 so cannot comment on that but here is the Java 7 download site: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html

@praveensas
Copy link

Hi, Do you solution to this. kindly help

@praveensas
Copy link

I am getting same issue. PLease see below

231
232 DATA null;
233 DECLARE JavaObj df("classfile/Classfile");
234 df.callDoubleMethod("comp", 1, 2, 3, r);
235 put r=;
236 RUN;

ERROR: Could not find class classfile/Classfile at line 233 column 23. Please ensure that the
CLASSPATH is correct.
ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.
java.lang.ClassNotFoundException: classfile.Classfile
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

237
238 %reset_classpath;
NOTE: Setting Java classpath back to its original state: C:\Program Files\Java\jdk1.8.0_181\bin

239 PROC OPTIONS option=jreoptions;
240 RUN;

SAS (r) Proprietary Software Release 9.4  TS1M1

JREOPTIONS=( -DPFS_TEMPLATE=C:\Program
Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\qrpfstpt.xml
-Djava.class.path=C:\PROGRA1\SASHome\SASVER1\eclipse\plugins\SASLAU1.JAR
-Djava.security.auth.login.config=C:\Program
Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.login.config
-Djava.security.policy=C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.policy
-Djava.system.class.loader=com.sas.app.AppClassLoader
-Dlog4j.configuration=file:/C:/Program%20Files/SASHome/SASFoundation/9.4/tkjava/sasmisc/sas.log4j.prop
erties -Dsas.app.class.path=C:\PROGRA
1\SASHome\SASVER1\eclipse\plugins\tkjava.jar
-Dsas.ext.config=C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.java.ext.config
-Dsas.jre.libjvm=C:\PROGRA
1\SASHome\SASPRI1\9.4\jre\bin\server\jvm.dll
-Dtkj.app.launch.config=C:\PROGRA
1\SASHome\SASVER~1\picklist -Xms128m -Xmx128m
)
Specifies the Java Runtime Environment options for SAS.
NOTE: PROCEDURE OPTIONS used (Total process time):
real time 0.09 seconds
cpu time 0.04 seconds

241
242 proc javainfo all; run;

PFS_TEMPLATE = C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\qrpfstpt.xml
awt.toolkit = sun.awt.windows.WToolkit
file.encoding = Cp1252
file.encoding.pkg = sun.io
file.separator =
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.awt.headless = false
java.awt.printerjob = sun.awt.windows.WPrinterJob
java.class.path = C:\PROGRA1\SASHome\SASVER1\eclipse\plugins\SASLAU1.JAR
java.class.version = 51.0
java.endorsed.dirs = C:\PROGRA
1\SASHome\SASPRI1\9.4\jre\lib\endorsed
java.ext.dirs = C:\PROGRA
1\SASHome\SASPRI1\9.4\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
java.home = C:\PROGRA
1\SASHome\SASPRI1\9.4\jre
java.io.tmpdir = C:\Users\PERSON
1\AppData\Local\Temp
java.library.path = C:\Program
Files\SASHome\SASFoundation\9.4\core\sasext;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:
Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;.
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.7.0_15-b03
java.security.auth.login.config = C:\Program
Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.login.config
java.security.policy = C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.policy
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 1.7
java.system.class.loader = com.sas.app.AppClassLoader
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.7.0_15
java.vm.info = mixed mode
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 1.7
java.vm.vendor = Oracle Corporation
java.vm.version = 23.7-b01
line.separator =

log4j.configuration =
file:/C:/Program%20Files/SASHome/SASFoundation/9.4/tkjava/sasmisc/sas.log4j.properties
os.arch = amd64
os.name = Windows 7
os.version = 6.1
path.separator = ;
sas.app.class.path = C:\PROGRA1\SASHome\SASVER1\eclipse\plugins\tkjava.jar
sas.ext.config = C:\Program Files\SASHome\SASFoundation\9.4\tkjava\sasmisc\sas.java.ext.config
sas.home = C:\Program Files\SASHome
sas.jre.libjvm = C:\PROGRA1\SASHome\SASPRI1\9.4\jre\bin\server\jvm.dll
sas.root = C:\Program Files\SASHome\SASFoundation\9.4
sas.tkjni =
sun.arch.data.model = 64
sun.awt.enableExtraMouseButtons = true
sun.boot.class.path =
C:\PROGRA1\SASHome\SASPRI1\9.4\jre\lib\resources.jar;C:\PROGRA1\SASHome\SASPRI1\9.4\jre\lib\rt.jar
;C:\PROGRA1\SASHome\SASPRI1\9.4\jre\lib\sunrsasign.jar;C:\PROGRA1\SASHome\SASPRI1\9.4\jre\lib\jsse
.jar;C:\PROGRA1\SASHome\SASPRI1\9.4\jre\lib\jce.jar;C:\PROGRA1\SASHome\SASPRI1\9.4\jre\lib\charset
s.jar;C:\PROGRA1\SASHome\SASPRI1\9.4\jre\lib\jfr.jar;C:\PROGRA1\SASHome\SASPRI1\9.4\jre\classes
sun.boot.library.path = C:\PROGRA1\SASHome\SASPRI1\9.4\jre\bin
sun.cpu.endian = little
sun.cpu.isalist = amd64
sun.desktop = windows
sun.io.unicode.encoding = UnicodeLittle
sun.jnu.encoding = Cp1252
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.os.patch.level = Service Pack 1
tkj.app.launch.config = C:\PROGRA1\SASHome\SASVER1\picklist
user.country = US
user.dir = C:\Users\Personal-PC
user.home = C:\Users\Personal-PC
user.language = en
user.name = Personal-PC
user.script =
user.timezone = Asia/Calcutta
user.variant =

NOTE: PROCEDURE JAVAINFO used (Total process time):
real time 0.10 seconds
cpu time 0.04 seconds

@rmyneni
Copy link

rmyneni commented Aug 23, 2018

@praveensas are you failing running code from repo enlighten-integration/SAS_Base_OpenSrcIntegration or just trying to use JavaObj in Base SAS. Either way, you (1) need to compile Java class(es) that you want to use and (2) add them to the CLASSPATH of Base SAS installation. The pdf in this repo explains how to do that with an example -- see sections "Compiling the provided java classes" and "Setting the Java CLASSPATH"

Your code is using:
DECLARE JavaObj df("classfile/Classfile");
but it should be something like this:
DECLARE javaobj j("dev.SASJavaExec", "arg1");
where dev.SASJavaExec is the Java class with package extension that you want to execute and arg1 is the argument it takes. And you need to place this package structure (for example dev/SASJavaExec.class) in a directory and add that directory to the CLASSPATH of Base SAS installation.

Hope this helps!

@filbert11
Copy link

hi,

i managed to run the check java class code perfectly without error but when i run the python code. it throws me this error.
image

@rmyneni
Copy link

rmyneni commented Mar 15, 2023

@filbert11 - looks like the code is trying to run the following command but not finding some file along the way - do you have all these directories specified correctly? and can you run this command ok say in windows command prompt?
"C:\Anaconda\python.exe" "C:\Users\a\Downloads\SAS\SAS_Base_OpenSrcIntegration\digitsdata_svm.py" "C:\Users\a\Downloads\SAS\SAS_Base_OpenSrcIntegration"

@filbert11
Copy link

Thank you for your assistance. managed to solve it after i change the python directory.

however, there is another error as highlighted in yellow.

image

@rmyneni
Copy link

rmyneni commented Mar 16, 2023

That error is coming directly from Python, maybe you don't have all the needed dependencies installed. Any line in the log that starts with "INFO: PROCESS OUTPUT >>>" is coming from Python.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants