Using and loading newer java classes...

Hi,
I am trying to use a feature from the newest release of java in my application.
Is it possible to find the exact class files within the jre and just put them amongst
my application's classes?
For example if I were to take the new transparency feature
from the latest release and use it on a computer that is not running the latest release of the java runtime?
Any ideas or help would be so great...
Thanx in advance!

BigDaddyLoveHandles wrote:
>
Also, what if i wrote a class that uses the new features, and catch a class not found exception
just on loading that class? so I could inform the user the latest jre needs to be downloaded to use transparency...In my mind, a cleaner approach is the following.
Right off the bat (main?) you can find out the version:
String version = System.getProperty("java.version");And decide what to do based on that. You even could have two versions of your app and chose the one that works with that version of the JRE!Thanx BigDaddyLoveHandles! :)
this is a great idea, i still hope i could find some kind of solution to using classes from a jre that is not installed some how...

Similar Messages

  • How can I compile and run other java classes from within an application?

    Hello there everyone! I really hope that someone can help me. I am writing a program that must be able to compile and run other java classes that are in different files, much like development environments like Kawa or Forte allow you to do.
    There has to be a way of doing this ( I hope!! ), but i can't seem to find it!!
    I have tried using this command to compile:
    Runtime.getRuntime().exec ("c:\\programs\\javac className.java");
    ...and this one to run:
    Runtime.getRuntime().exec ("c:\\programs\\java className");
    ...but neither works!!! I can compile and run classes that are in the same file as my application, but I can't get it to work at all for files in different directories or files.
    PLEASE, PLEASE, PLEASE help me - i've run out of ideas, and i need this to be working in 3 days!!!
    Thank you very much for any help anyone can give me, I really appreciate it!! Thanks again!!
    Adrian ( ...in distress!! )

    public class JavaCompiler{
       public static void main(String[] args)throws Exception{ //sorry bout the laziness
          if(args == null || args.length != 1){
             System.out.println("Usage: java JavaCompiler MyClass.java");
             System.exit(0);
          String className = args[0];
          Runtime rt = Runtime.getRuntime();
          Process p = rt.exec("javac " + className); //consider setting cpath for this
          p.waitFor();
          //now try to run after it is done.
          p = rt.exec("java " + className.substring(0, (className.length() - ".java".length()));
          p.waitFor();
          //do some other stuff
    }This should get you going. You may consider looking into the System.getProperty() method in order to determine the type of OS it is running on in order to findo out what command to run. I know that the sun tool listed above is nice, but by my understanding the sun tools provided are not guaranteed to stay the same. I'm no expert on this matter, but that is one of the reasons there is no API documentation for those tools. Also, I don't believe those tools come packaged with the JRE. (Of course if you are making an IDE it will be expected that the user has an sdk installed. Good luck with figuring this thing out.

  • Problem when loading simple java class in Oracle

    Hi,
    I am using loadjava to load the java class in the oracle database. But it is failing. Can some one please help me out with this.
    Command.
    loadjava -thin -user username/password@zrtph0ja:1521:database -resolve firstProcedure.class
    Errors:
    Error while computing shortname of firstProcedure
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error while computing shortname of firstProcedure
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-29521: referenced name java/io/PrintStream could not be found
    ORA-29521: referenced name java/lang/Object could not be found
    ORA-29521: referenced name java/lang/String could not be found
    ORA-29521: referenced name java/lang/StringBuffer could not be found
    ORA-29521: referenced name java/lang/System could not be found
    loadjava: 7 errors
    Please help.
    Regards
    Sudhir
    null

    U havent installed JServer in ur DBMS.
    Read the Oracle 8i JServer Manual for
    manually installing the Oracle JVM.

  • What is the workflow to compile and load an external class as a runtime library?

    I have a set of classes (with some large embeds) that I only want to load one by one at runtime as needed.
    I think that I need to compile each of these classes into a separate SWF and use one of the available loaders out there to load and link to them dynamically at runtime (am I on track so far?).
    I got a little mixed up in the details though, so I'd just like someone to give me the basic rundown on doing this, get the right termonology, and if you have any reference to the right tutorial on doing it, all the better!
    I'm using flex builder, and this is to be used in a flex application.
    Thanks!
    David

    Hi, thanks for the response!
    A couple of questions arise:
    1) If I use this approach am I correct in my understanding that all classes referenced by my library will be compiled into the final SWF? That will create a lot of duplicated classes since those classes are already being used and loaded in the main SWF. Is there a way to avoid this duplication problem?
    2) In trying to play with this approach I ran into a problem. When I create the SWF it fails to find a class Vector ("Type was not found or was not a compile-time constant: Vector"), I think I understand that this is because I am targeting flash player 9, but the code I am using require 10. I can't seem to find an option to change the target in a flex library project as I can in a regular actionscript or MXML project.
    Dave

  • Import new java classes into a running programm

    Hello, i have a small Java problem, i hope somebody knows an answer ...
    I try to write a Java Programm, this programm starts and load a new class, this class is not defined inside the running programm, but the running programm should use the new class.
    example:
    // a class file in a directory somewhere at my harddisk
    public void class X
    void doSomething()
    //Print "Hello world"
    start programm A
    Programm A does something, but doesn�t "know" class X, class X is not compiled with program A
    after some seconds, A should load class X.
    if (M == N) "import class X"
    // At this moment, Programm A knows class X
    X NewObjektX = new X();
    NewObjektX.doSometing();
    Thats my problem :)
    I am sorry about my bad english, but its sadly not my first language.

    Hello :)
    Thx for an answer, i tried your solution, but i get another problem.
    The type to create an object ist unknown.
    i?ll post my exmaple code :
    This class is not compiled with the main programm, only the class file is inside the directory of the main program.
    public class SimpleClass
         int Information = 0;
         void printOnScreen()
             System.out.println("Varibale of the class:"
               + this.Information);   
    This is the main programm:
    public class Main {
         public static void main(String[] args)
              try
                Class newClass = Class.forName("SimpleClass");
                Object instance = newClass.newInstance(); 
                  System.out.println(instance.getClass());
                  // At this point no errors, the tpye of instance is
                     "SimpleClass"
                  // This line occurs an error, the type "SimpleClass" is
                  // unknown.
                SimpleClass newClassInstance = (SimpleClass) instance;
              catch (ClassNotFoundException e)
                System.out.println("Can?t open Class");
                System.err.println(e.getMessage());
              catch (InstantiationException e)
               System.out.println("Error1");
               System.err.println(e.getMessage());
              catch (IllegalAccessException e)
                 System.out.println("Error2");
               System.err.println(e.getMessage());
          } // public static void main(String[] args)
    } // public class MainI tried another solution with inheritance, i programmed a superclass, and choose the superclass as the type (the Superclass was compiled with the main programm).
    The SimpleClass extends Superclass.
    // works fine, but i dont want this type of solution :)
    Superclass newClassInstance = (Superclass) instance;
    How cann i solve the "unknown type" problem ?
    SimpleClass newClassInstance = (SimpleClass) instance;

  • Passing numerical variables to and from a Java class

    I'm trying to do something that seems like it should be fairly simple, but apparently it isn't. I'm new to Java and JDBC, so I'm hoping that I'm missing something fundamental and fairly basic.
    Basically, I want to pass a set of (number) variables to a Java class from a PL/SQL Procedure, and get back a series of numbers based on calculations to the first set of numbers. (In my real world project, I have to perform a series of matrix calculations to determine regression parameters for two sets of data, but we'll keep this simple.) However, I can find nothing that tells me how to do this, and I'm receiving a series of errors when I attempt it.
    For example, let's say I want to send in two decimal numbers, a and b, and receive back the sum s, the difference d, the product p and the quotient q. So, the java class would be:
    * MathEx.java
    class MathEx {
    public static void main(double a, double b, double sum, double diff, double prod, double quo) {
    sum = a + b;
    diff = a - b;
    prod = a * b;
    quo = a / b;
    Fairly simple, right? It compiles fine using "javac MathEx.java", and then I load the class into the database:
    loadjava -u steve/steve MathEx.class
    Everything works great. Now, I create a wrapper Procedure. This is where the problem comes in. How do I declare the incoming and outgoing parameters in the Procedure? No matter what I try, I get " the declaration of "MathEx.main([whatever])" is incomplete or malformed"
    The procedure I'm trying is:
    create or replace procedure Call_MathEx
    a NUMBER,
    b NUMBER,
    s NUMBER,
    d NUMBER,
    p NUMBER,
    q NUMBER
    AS
    language JAVA
    name 'MathEx.main(oracle.sql.NUMBER,oracle.sql.NUMBER,
    oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,)';
    I've tried the following values for possible variable types in the "name 'MathEx.main(" statement:
    oracle.sql.NUMBER
    java.lang.Number
    java.lang.Double
    java.Math.BigDecimal
    The only thing I can get to work is if I just use "java.lang.string[]" and send everything at once, then use parseDouble() to read the parameters inside the Java class. However, that makes it impossible to then read the new values of the sum, difference, product and quotient in the calling procedure, since the variable retain the same value as before the call to the Java class.
    Any help is greatly appreciated.

    Java Stored Procedures Developers Guide (part of the docs and here on OTN) would probably help.
    I suspect you need:
    create or replace procedure Call_MathEx
    a IN NUMBER,
    b IN NUMBER,
    s OUT NUMBER,
    d OUT NUMBER,
    p OUT NUMBER,
    q OUT NUMBER
    AS
    language JAVA
    name 'MathEx.main(oracle.sql.NUMBER,oracle.sql.NUMBER,
    oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,)';
    Not sure, I always let JDeveloper handle it for me :)

  • Error loading a java class to oracle db

    hi,
    my oracle server: 8i Enterprise Edition Release 8.1.7.0.0
    i want to load a simple java class into my oracle server.
    java source:
    public class Ping
         java.lang.String server;
         public static void main(java.lang.String[] args)
              System.out.println(new Ping().runCmd(args[0]));
         public static java.lang.String runCmd(String cmd)
    boolean result=false;
    int timeout=5000;
    try {            
    java.net.InetAddress byName=java.net.InetAddress.getByName(cmd);
                   result=byName.isReachable(timeout);
    catch(java.io.IOException e)
    e.printStackTrace();
         java.lang.String retVal=java.lang.Boolean.toString(result);
              return retVal;
    after compiling the java file. i'm using loadjava at dos prompt.
    loadjava -user uname/pwd@db -resolve Ping.class
    this command results in
    ORA-29545: badly formed class:
    loadjava: 1 errors
    alternatively i had used a command
    loadjava -user uname/pwd@db -noverify -resolve Ping.class
    this command results in
    Error while turning off verifier
    ORA-29532: Java call terminated by uncaught Java exception: java.security.Ac
    cessControlException: the Permission (oracle.aurora.security.JServerPermission V
    erifier ) has not been granted by dbms_java.grant_permission to SchemaProtection
    Domain(SMSPGS|PolicyTableProxy(SMSPGS))
    ORA-29545: badly formed class:
    loadjava: 2 errors
    but user is having sufficient rights (javasyspriv)
    what is wrong above, please help me.
    regards,
    s.mohamed asif

    hi,
    thanks for your response
    Ping.class just checks whether the specified node is reachable or not.
    result=byName.isReachable(timeout);
    the jdk loaded in oracle DB is older one and the method above java.net.InetAddress.isReachable(java.lang.int) is available since
    jdk 1.5
    source:
    public class Ping
    java.lang.String server;
    public static void main(java.lang.String[] args)
    System.out.println(new Ping().runCmd(args[0]));
    public static java.lang.String runCmd(String cmd)
    boolean result=false;
    int timeout=5000;
    try {
    java.net.InetAddress byName=java.net.InetAddress.getByName(cmd);
    result=byName.isReachable(timeout);
    catch(java.io.IOException e)
    e.printStackTrace();
    java.lang.String retVal=java.lang.Boolean.toString(result);
    return retVal;
    }how to load the new jdk set into existing oracle db server and replace the existing jdk.
    what can be done to achieve this ?
    regards,
    s.mohamed asif

  • How to load a java class at server start-up

    Hi,
    I have one custome java class that is being referenced by all the applications deployed in OC4J container. How can I load that class automatically and be evailable in the path at server start-up time. Is there an option available to give the class name that also gets loaded automatically.
    Thanks

    To me, you have two mixed issues.
    1. OC4J supports a startup/shutdown model where a named class will be invoked when the container is started (or stopped).
    This is described in the doc here:
    http://download-west.oracle.com/docs/cd/B32110_01/web.1013/b28952/startclas.htm#CIHECEIB
    Note that this specifically calls the methods that are implemented from the respective OC4JShutdown and OC4JStartup interfaces -- the class that is instantiated and called here is not available to all other applications by default. This is more to suit the need where something needs to be done when the container is started/stopped.
    2 The next option is where you just want to make a class available to all applications deployed to the container. For this we provide the shared-library mechanism. Using this you can either make use of the implicit global.libraries shared-lib in which you simply drop JAR files into the j2ee/home/applib directory whereupon the classes will become available by default to all applications. Or you can choose to install a shared-library that contains your specific classes (in a JAR file) and then import that into the default application whereupon the configuration will be inherited by all deployed applications.
    cheers
    -steve-

  • How to load a java class when application is at first time browsed.

    Hi
    How can i load a simple java class on application startup.
    For servlet it could be done using "load on startup" tag in web.xml
    but how could the same be achieved for a simple java class.
    Thanks

    Hi
    Code is given below....
    package com;
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Test {
    Test()
         HttpServletRequest request=null;
         HttpServletResponse response=null;
         RequestDispatcher requestDispatcher = request.getRequestDispatcher("a.jsp");
         try {
              requestDispatcher.forward(request,response);
         } catch (ServletException e) {
              System.out.println("success");
              e.printStackTrace();
         } catch (IOException e) {
              System.out.println("success 1");
              e.printStackTrace();
         finally
              System.out.println("success 2");
         System.out.println("success 3");
    }Web.xml :
    <servlet>
            <servlet-name>simple</servlet-name>
            <servlet-class>com.Test</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
      <servlet-mapping>
          <servlet-name>simple</servlet-name>
          <url-pattern>/init.do</url-pattern>
        </servlet-mapping>Error Trace :
    org.apache.catalina.core.StandardContext loadOnStartup
    SEVERE: Servlet /DispatcherTest threw load() exception
    java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.Test with modifiers ""
         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
         at java.lang.Class.newInstance0(Class.java:344)
         at java.lang.Class.newInstance(Class.java:303)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
         at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
         at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1069)
         at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1162)
         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
         at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1304)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
         at java.lang.Thread.run(Thread.java:595)

  • Calling a WL Webservice using wsse from a java class

    One of the business partners I am integrating with needs to call my web service
    which is secured with UserTokens. The buiness partner is running in a J2EE environment,
    but not BEA. They will be calling the web service using a Java Class. Do I need
    to create a Java proxy for them to be able to reach my web service? Do I run the
    java proxy file on my side, or do i give it to them to run? Do i need to provide
    them with a client security policy file?
    Any help is appricated
    Thanks
    Linda

    Hi Linda,
    Currently we support only two types of tokens: UsernameToken and
    BinarySecurityToken, see the docs [1] for additional details. The
    policy file you are referring to is WLW specific and will not be
    portable. We are working towards the (yet to be finalized) WS-Policy
    framework for the next major release.
    Regards,
    Bruce
    [1]
    http://edocs.bea.com/wls/docs81/webserv/security.html#1082126
    [2]
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/security/ws-security/ovwWebServiceSecurity.html
    [3]
    http://ftpna2.bea.com/pub/downloads/WS-Policy.pdf
    Linda Gilligan wrote:
    >
    One of the business partners I am integrating with needs to call my web service
    which is secured with UserTokens. The buiness partner is running in a J2EE environment,
    but not BEA. They will be calling the web service using a Java Class. Do I need
    to create a Java proxy for them to be able to reach my web service? Do I run the
    java proxy file on my side, or do i give it to them to run? Do i need to provide
    them with a client security policy file?
    Any help is appricated
    Thanks
    Linda

  • How to use junit for a java class in netbeans

    hi friends,
    im new to java(fresher) and i need step by step creation of junit class for a java class in net beans6.5.so anybody plz explain me in detail.......

    Hi venkatakrishna.chaithanya,
    With NetBeans :
    - hit F1 to get the Help screen;
    - select the Search tab;
    - enter the word junit;
    - in the left pane, select *7 Creating a JUnit Test*;
    - read the intructions displayed in the right pane.

  • How to clear player and load new movie?

    Windows Vista, Quicktime 7.2
    When watching a movie in Quicktime, I want to be able to click another movie and have Quicktime clear the existing movie, and load and play the new one.
    At present, another player is automatically opened. I have unchecked the preferences box "Open movies in new players"
    Thanks for your help - Bob

    Scott,
    I created a new link f?p=&FLOW_ID.:3:&SESSION.::NO:3
    and the text fields are still filled up.
    Page 3 is loaded after passing sno from page 2.
    While loading page 3 it fetches record from database and record values are filled in text fields. When list link 'New' is clicked it loads page 3 with out clearing the text fields.
    Any solution from any one.

  • How can I use JVM  instructions from Java classes?

    Hello,
    I want to use JVM instructions in my Java classes. How can I achieve this?
    Should I include a library to my project or something else?

    What on earth are you talking about?

  • Just synced my 3GS and loaded new 5.0. my apps which were password protected photos and another for credit card info did not transfer back to phone. Where are they?

    Just synched my 3GS and loaded 5.0. My photo vault and credit card vault secure apps are gone. Any idea how to recover or where they might be?

    If for some reason you failed to transfer them to your computer before updating, then you would have to redownload them.
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • How to store and load in java using mapping

    I am doing my project in java, my project consists of producing a card game.
    I my game at the end of each round the computer will ask the player if he/she wants to save the game. I have looked at some methods on how to do this. It seams that I need a type of mapping but how.
    I want to take a String (which is entered by the player) and to this String I want to store various peices of data that can be loaded up later.
    The data that I want to store are has follows
    1. Name of the player - String
    2. Name of the computer- String
    3. Points of computer sofar- Int
    4. Points of player sofar - Int
    5. Target points- Int
    If there is a better way then please tell me. thankyou

    The format of the saved game could be anything. An easy way to do this is by using the MessageFormat class.
    Let's say you use the tab character as a delimiter, and you want to write two strings and 3 ints:
    MessageFormat mf = new MessageFormat("{0}\t{1}\t{2,number}\t{3,number}\t{4,number}";
    Object[] o = new Object[5];
    o[0] = playerName;
    o[1] = computerName;
    o[2] = new Integer(computerPoints);
    o[3] = new Integer(playerPoints);
    o[4] = new Integer(targetPoints);
    String formatted = mf.format(o);
    PrintWriter out = new PrintWriter(new FileWriter("save.txt"));
    out.println(formatted);
    out.close();
    // reading:
    BufferedReader in = new BufferedReader(new FileReader("save.txt"));
    String s = in.readLine();
    Object[] values = mf.parse(s);
    playerName = (String)values[0];
    computerName = (String)values[1];
    computerScore = ((Number)values[2]).intValue();
    playerScore = ((Number)values[3]).intValue();
    targetScore = ((Number)values[4]).intValue();You could also just write each value on its own line and not using MessageFormat, but just read the values line by line and convert String to ints when needed.

Maybe you are looking for

  • New AE CC 13.1.1.3

    Hi, Does anyone have a problem rendering with the new AE update? I've updated in the middle of a project and I'm having terrible issues with colors. It doesn't matter what codec I use, everything looks washed out. I can work at all. Didn't happen wit

  • Remedy system to Portal - HTTPS problem

    Hello folks,     I am integrating remedy system to portal using R/3. We are not able to consume the webservice directly from the Iview using portal services(not supporting for the remedy system). So we have created a RFM(using SOAP). Portal connects

  • Trying to capture DV material, log and capture spinning beach ball

    I have not worked in DV for quite awhile. I am trying to just capture a few minutes and the log and capture window gives me the beach ball of death when I hit capture now. If I hit play all seems fine, but try and capture and the beach ball shows up.

  • Serious problem with TitledBorder(jPanel)

    I have a serious problem with TitledBorder(jPanel) Here, I have two class the first it contains a jTabbedPane ( class_jTabbedPane)qui call the second which contains a jPanel (Ptableau) which contains a jTable in a jPanel with TitledBorder The problem

  • Exception inspite of successful build

    i am running the following code it shows no exception if i dont click inside the applet but if i click it shows the following exception. what could be the possible reason for that Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: