1 2 Previous Next 15 Replies Latest reply: Sep 2, 2013 8:57 AM by usman_noshahi Go to original post RSS
      • 15. Re: how to use cmd in host();
        usman_noshahi

        I tried this code 3 days back but it didn’t work because of environment variables ,

        Here is the solution.

         

        Things that was wrong.

         

        1. Netbeans IDE set variables paths for "java" automatically but “javac” keyword still unrecognized by CMD.
        2. When we call any file using host(); keyword ,  Not setting Environment variable takes the control to the cmd.exe which exists in %devehome%\cmd.exe that couses “java” command not to be recognized .
        3. Wrong command in batch file to run .jar file.

         

        Solution:

         

        • Set the Enviroment veriable path where jdk is installed. For example

         

        C:\Program Files\Java\jdk1.6.0_30\bin
        

         

        • Make new variable named JAVA_HOME and put the same value.

         

        • Keep java and javac version same .. run this command to verify.

         

        java -version
        javac -version
        

         

         

        • Once your commands give you versions details in case if they provide the same output then you can try your batch file just giving your .jar file exect path WITHOUT any qoutation marks or any thing like this

         

        cmd.exe /c start “dirctory”.

         


        • Just write in your batch direct path like this

         

        D:\filepath\filename.jar
        

         

        • Then try to run this batch file directly by double clicking to find if there is no error , for this use this

         

        D:\filepath\filename.jar > d:\error.text
        

         

        • Once you verify then launch this file form your oracle forms like this

         

        begin
        host('d:\filepath\filename.bat');
        end;
        
        

         

         

        during this all time I noticed that oracle form runs .exe file very quickly for this you can made .exe file by using c++ code (use any IDE which you like)

         

        #include "stdafx.h"
        #include "stdlib.h"
        
        using namespace System;
        
        int main(array<System::String ^> ^args)
        {
              system("D:\\filepath\\filename.bat");
            return 0;
        }
        

         

        Things that to be taken under consideration

        Be aware of the order of Environment variables , for example if you have ORACLE ODBC(DATASOURCE) SYSTEM DNS configured then keep the %oraclehomepathBINdirectory%  at first number in class path then put the JDK BIN directory path after this one otherwise ODBC will give you error.

         

        If you don’t have the same versions of java and javac then it will create lot of problems to call another .jar file not only from oracle forms but also from java JFRAMFORM .

         

         

        thanks.

        1 2 Previous Next