This discussion is archived
11 Replies Latest reply: Jul 20, 2013 3:46 AM by Sachinmrt RSS

How to run the oracle form in linux system

Sachinmrt Explorer
Currently Being Moderated

Hello all,

 

My config is :-

 

Forms [32 Bit] Version 10.1.2.0.2 (Production)

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

 

 

I can easily run my on Windows and Linux platform untill i am not use java bean in my form. After using the getMacaddress JAVA BEAN. I am not able to run my form on linux platform. If i remove the java bean from my form than form will run on linux.

 

I am not familiar with linux so i am not able to trace the problem basicaly i don't  know which version of jre is used by linux system and i don't know how to find it.

 

Please guide me.

  • 1. Re: How to run the oracle form in linux system
    Christian Erlinger Guru
    Currently Being Moderated

    I don't know what the getMacaddress Java Bean does, but did you take a look at the source if you have it? Maybe it runs some platform specific stuff? If it calls e.g. ipconfig this wouldn't work under Linux.

     

    cheers

  • 2. Re: How to run the oracle form in linux system
    lake Journeyer
    Currently Being Moderated

    The jre is a browser plugin so the version is found the same way as it is on windows more or less, by asking the browser. Suppose they had firefox or chrome, it would be about:plugins. If it's some other browser like nautilus etc then you would need to research that browser to find out how to tell the plugin version.

     

    Plan b query it from the applet. This web site has very good info about the jre plugin detection:

    http://www.pinlady.net/PluginDetect/Java/

     

    (Fascinating what they say about deployment toolkit (a plugin in the browser). I have had the biggest problems ever with that software. Once it gets installed there is no way removing it. I'd highly recommend NEVER allowing the deployment toolkit to get installed in any browser or you can spend many hours trying to remove it. No one knows what it does but I can tell you that it is highly capable of stopping the jre of ever being called successfully. The worst ever problem is the user having installed the jre 7 with the deployment toolkit and then you are trying to get rid of 7 and go back to 6. With some versions of the jre 7 it was nearly utterly impossible to get rid of it. No software program should be deployment that is unremovable! )

     

    I can create possibly the same type of problem on windows with my bean (that never works. Way to go that you got one to work ever!) that it causes some kind of loop or hanging in the jre and then it is toast afterward. Java has to be killed on the client in that case which takes expertise with the operating system in question.

     

    Beans are hard to do. I know Francois works very hard to help the galaxy with beans. Thanks Francois! But we could use more resources so more customers could make more forms enhancements via the bean (or javascript or html5 etc etc) route.

  • 3. Re: How to run the oracle form in linux system
    Sachinmrt Explorer
    Currently Being Moderated

    Thanks for your reply,

    My Java code is

    [PRE]

     

     

    import java.io.BufferedReader;

    import java.io.File;

    import java.io.IOException;

    import java.io.InputStreamReader;

    import java.net.InetAddress;

    import java.net.UnknownHostException;

    import oracle.forms.ui.*;

    import oracle.forms.properties.*;

     

     

    public class getMacAddress extends VBean

    {

     

     

    public getMacAddress()

    {

    System.out.println("Bean has been initialised");

    }

     

     

    /* public static void main(String[] args)

    {

    String res = getAddress();

    System.out.println(res);

    } */

     

     

    public String getAddress()

    {

     

     

    String macAddress = null;

    String getAddress = null;

     

     

    Process p = null;

    BufferedReader in = null;

     

     

    try {

    String osname = System.getProperty("os.name");

    if (osname.startsWith("Windows")) {

    p = Runtime.getRuntime().exec( new String[] { "ipconfig",

    "/all" }, null);

     

     

    }

    // Solaris code must appear before the generic code

    else if (osname.startsWith("Solaris") || osname.startsWith("SunOS"))

    {

    String hostName = getFirstLineOfCommand(new String[] { "uname",

    "-n" });

    if (hostName != null) {

    p = Runtime.getRuntime().exec(

    new String[] { "/usr/sbin/arp", hostName }, null);

    }

    }

    else if (new File("/usr/sbin/lanscan").exists()) {

    p = Runtime.getRuntime().exec(

    new String[] { "/usr/sbin/lanscan" }, null);

    }

    else if (new File("/sbin/ifconfig").exists()) {

    p = Runtime.getRuntime().exec(

    new String[] { "/sbin/ifconfig", "-a" }, null);

    }

     

     

    if (p != null) {

    in = new BufferedReader(new InputStreamReader(

    p.getInputStream()), 128);

    String l = null;

    while ((l = in.readLine()) != null) {

    macAddress = parse(l);

    if (macAddress != null && parseShort(macAddress) != 0xff)

    break;

    }

    }

     

     

    }

    catch(IOException e)

    {

    e.printStackTrace();

    }

     

     

    catch(Exception e)

    {

    e.printStackTrace();

    }

     

     

    return macAddress;

    }

     

     

     

     

    public String parse(String in)

    {

    int hexStart = in.indexOf("0x");

    if (hexStart != -1 && in.indexOf("ETHER") != -1) {

    int hexEnd = in.indexOf(' ', hexStart);

    if (hexEnd > hexStart + 2) {

    return in.substring(hexStart, hexEnd);

    }

    }

     

     

    int octets = 0;

    int lastIndex, old, end;

     

     

    lastIndex = in.lastIndexOf('-');

     

     

    if (lastIndex > in.length() - 2) return null;

     

     

    end = Math.min(in.length(), lastIndex + 3);

     

     

    ++octets;

    old = lastIndex;

    while (octets != 5 && lastIndex != -1 && lastIndex > 1) {

    lastIndex = in.lastIndexOf('-', --lastIndex);

    if (old - lastIndex == 3 || old - lastIndex == 2) {

    ++octets;

    old = lastIndex;

    }

    }

     

     

    if (octets == 5 && lastIndex > 1) {

    return in.substring(lastIndex - 2, end).trim();

    }

    return null;

    }

     

     

     

     

    public short parseShort(String s) throws NullPointerException {

    s = s.toLowerCase();

    short out = 0;

    byte shifts = 0;

    char c;

    for (int i = 0; i < s.length() && shifts < 4; i++) { c = s.charAt(i); if ((c > 47) && (c < 58)) { out <<= 4; ++shifts; out |= c - 48; } else if ((c > 96) && (c < 103)) { ++shifts; out <<= 4; out |= c - 87; } } return out; } public String getFirstLineOfCommand(String[] commands) throws IOException { Process p = null; BufferedReader reader = null; try { p = Runtime.getRuntime().exec(commands); reader = new BufferedReader(new InputStreamReader( p.getInputStream()), 128); return reader.readLine(); } finally { if (p != null) { if (reader != null) { try { reader.close(); } catch (IOException ex) {} } try { p.getErrorStream().close(); } catch (IOException ex) {} try { p.getOutputStream().close(); } catch (IOException ex) {} p.destroy(); } } } }

    [/PRE]

     

     

    This code handle the both Linux and Windows. Basically i faced the problem in linux platform, i don't know how to check java version in Linux and how to install the new java version.

  • 4. Re: How to run the oracle form in linux system
    Christian Erlinger Guru
    Currently Being Moderated

    Since you are using Forms 10.1.2 and JInit isn't an option anymore considering it doesn't work with nowadays browsers I suppose using JPI >= 1.6.x. is feasible if you are not already using it.

     

    So instead you could use NetworkInterface.getHardwareAdress:

     

    http://docs.oracle.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress%28%29

     

    you could get a list of all Interfaces available too:

    NetworkInterface (Java Platform SE 6)

     

    cheers

  • 5. Re: How to run the oracle form in linux system
    Christian Erlinger Guru
    Currently Being Moderated
    i don't know how to check java version in Linux and how to install the new java version.

     

    java -version

     

    Maybe install a newer version if needed. Then this: http://www.oracle.com/technetwork/java/javase/manual-plugin-install-linux-136395.html

     

    sounds like a good start.

     

    cheers

  • 6. Re: How to run the oracle form in linux system
    Sachinmrt Explorer
    Currently Being Moderated

    As per my knowledge oracle jdeveloper 10 g support the JPI >= 1.5.x. and NetworkInterface.getHardwareAdress

    is supported by the JPI >= 1.6.x.

  • 7. Re: How to run the oracle form in linux system
    Sachinmrt Explorer
    Currently Being Moderated

    Sir,

     

    As per your suggestion i am working on your given link.

  • 8. Re: How to run the oracle form in linux system
    Christian Erlinger Guru
    Currently Being Moderated

    JDeveloper isn't tied to a specific JDK Version; you'd simply have to install a newer version and add it under Tools => Manage Libraries => J2SE Definitions.

     

    cheers

  • 9. Re: How to run the oracle form in linux system
    Sachinmrt Explorer
    Currently Being Moderated

    After doing the lots of afford i have done it.

    This link is really helpful.

    [code]

    Maybe install a newer version if needed. Then this:http://www.oracle.com/technetwork/java/javase/manual-plugin-install-linux-136395.html

    [/code]

     

    Sir now i am able to run the form on linux system. Kindly guide me how to update the JDK version of JDeveloper.

    Please provide the steps. Still i am not able to get the Linux system Mac Id. After update the JDK may be i able to use NetworkInterface.getHardwareAdress.

  • 10. Re: How to run the oracle form in linux system
    Christian Erlinger Guru
    Currently Being Moderated

    As said in my previous post: download a JDK (e.g. from here: Java Archive Downloads - Java SE 6)

    and install it. Then add it under Tools => Manage Libraries => J2SE Definitions.

     

    cheers

  • 11. Re: How to run the oracle form in linux system
    Sachinmrt Explorer
    Currently Being Moderated

    Now i install the jdk 1.6.0_20 and add into the jdeveloper 10.1.3.

    and i change my code for get mac id is -

     

     

    package demo;

    import java.net.InetAddress;

    import java.net.NetworkInterface;

    import java.net.SocketException;

    import java.net.UnknownHostException;

     

    public class App{

     

       public static void main(String[] args){

     

    InetAddress ip;

    try {

     

    ip = InetAddress.getLocalHost();

    System.out.println("Current IP address : " + ip.getHostAddress());

     

    NetworkInterface network = NetworkInterface.getByInetAddress(ip);

     

    byte[] mac = network.getHardwareAddress();

     

    System.out.print("Current MAC address : ");

     

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < mac.length; i++) {

    sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));

    }

    System.out.println(sb.toString());

     

    } catch (UnknownHostException e) {

     

    e.printStackTrace();

     

    } catch (SocketException e){

     

    e.printStackTrace();

     

    }

     

       }

     

    }



    in form i create one jave bean area and add the implement class is

    demo.get_info.


    and on B1 (button) when-button-pressed


    :T1 :=GET_CUSTOM_PROPERTY('BEAN_MAC',1,'get_info');



    No error comes and no out put comes. So please guide me how to use the getHardwareAddress to get mac id.


Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points