Set classpath from java code

Hi,
Is it possible to set new classpath from java code? Something like System.setClasspath(String);
Many thanks
Miso

You aren't the first one to wonder whether that would work, so don't call yourself stupid on that account.
Not taking 15 minutes to set up and run a test to actually see if it works... well, if you really needed the answer, that would be different.

Similar Messages

  • How to set classpath from java class ??

    I have tried to use System.setProperty("java.class.path", "my class path string ") to set classpath dynamically. But it is not working. How to set it dynamically from java class ?? Thanks , gary

    Look into the java.net.URLClassLoader. You can't set the classpath after the fact but you can specify URL's that will checked when you try to load a class with that loader.

  • How to set classpath from java application

    in my ian using Runtine.exec();
    here the code
    String cmd[]={"cmd.exe","/c","path=C:\\j2sdk1.4.2_03\\bin\\;"};
              Runtime runtime = Runtime.getRuntime();
              Process setPathProc = runtime.exec(cmd);
              Process proc = runtime.exec("javac "+path+"\\"+clsname+".java");
    it working when ian running the application class from command, but when iam creating a jar file and running it was not working,,
    any suggestion

    hi kaj,
    my problem is ,
    In my application i have to compile one java file and
    create class file for that java file, here before
    creating i have to set class path, am i right?
    so in my program only first i have to set class path,
    and later i have to compile, so, in my code i have
    mentioned the details about to set class path and
    compile the program, r u getting what iam telling,
    please help me, if u know anything,
    thanks

  • How i can set dropDown item to 6th item from java code ?

    Hi
    Thank you for reading my post.
    how i can set dropDown item to 6th item from java code ?
    i have the value field of database and i can use it to set selected item of DropDown.
    so : can i use value field to set the selected item ?
    Thank u.

    Hi,
    Please go through the following thread which discusses about setting teh selected item for a dropdown:
    http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=50697
    Hope it helps
    Cheers
    Giri

  • Starting exetutable java file from java code

    Hi I was wondering how I can start a executable java file from java code?
    thanks

    Hi Mkaveli,
    Yes, it's possible. If you have a JAR executable, you've just to call the main method of its starter class. For a simple executable class, just call its main method.
    This way :
    SomeStarter.main(null); // if there's no argumentSmall precision : the executable JAR or class must be specified in the classpath of your application.

  • How to modify an existing xml file from java code.

    Hi
    I have worked on creating a new xml file from java code using xmlbeans.But if i try to modify an already existing file using java code I am unable to get errorfree xmlfile.
    For example if xml file(studlist.xml) is as below:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    Now suppose i have set name to victor using student.setName,
    and set age to 20 using setAge from javacode,
    the new xml file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    <Student>
              <Name>victor</Name>
              <Age>20</Age>
         </Student>
    As observed this is not a valid xml file.But how can i modify without any errors?

    I know it's an old post, but I found this while doing a google search for something else, and don't like to leave it un-aswered
    Just in case anyone has a similar problem... In this case the new elements have been appended outside of the root element
    What you need to do is first get the root element and then append the new children to that, there are several ways of getting the root element, which depend on what you want to do with the elements you get back here's a simple (incomplete) way.
    // gets the root element of the specified file (code not shown)
    Element rootElement= new SAXReader().read(file).getRootElement();Then just append the new elements as below (this is non-generic code and would need to be modified for your situation)
    // write a new student element
    Element student = document.createElement("Student");  // creates the new student
    rootElement.appendChild(student); // ***appends it to the root element***
    Element name = document.createElement("Name"); // creates the name element
    name.appendChild(document.createTextNode("Fred")); // adds the name text to the name element
    student.appendChild(name); // appends the name to the student
    Element age= document.createElement("Age"); // creates the age element
    age.appendChild(document.createTextNode("26")); // adds the age text to the age element
    student.appendChild(age); // appends the name to the studentThen flush ya buffers or whatever and write the file
    Edited by: Dream-Scourge on Apr 23, 2008 11:10 AM

  • Programatically calling control flows from java code

    Hi all,
    I have a bounded taskFlow that uses pageFragments. This flow is a region in a page(.jspx).
    In my page fragment, I have a inputComboboxListOfValues with a ValueChangeListener code in a java bean.
    I want when a value is changed, to programatically call "controll flow" (this one has: "From Activity Id" -the page fragment with that inputComboboxListOfValues, and "To Activity Id" - the default Activity on this task Flow).
    So when the value change, practically I want to restart the flow programatically and pass the selected value as input parameter.
    Since the inputComboboxListOfValues is not like a button where in the "Action" property you can set the Control Flow and navigate somewhere, the only option I have is to programatically cause navigation from java code (example: the value change listener code).
    Can this be achieved?
    Any advice is helpfull.

    Hi,
    Absolutely, you can do it using the NavigationHandler. Try the following in you value change listener:
    FacesContext context = FacesContext.getcurrentInstance();
    NavigationHandler handler = context.getApplication().getNavigationHandler();
    handler.handleNavigation(context, null, outcome);
    // Render the response after that phase, the button actions should not be called
    context.renderResponse();
    // Add the following line if you want to prevent further value change listeners to be called
    // throw new AbortProcessingException();Regards,
    ~ Simon

  • Generation of xml file from java code

    hi,
    I want to manipulate data in a xml file with java code.I have read data from xml file and also changed it. But i am unable to covert it again in xml file from java code. Can you please tell me how i can do this?

    Let me know which parser are you using currently for reading xml files so that i assist you. For now, you can refer to STAX Parser API under this link
    http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP3.html

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • Calling a javascript function from java code and getting tha value in Java

    Hi,
    I would like to call a Java script function confirmRemove() from Java code upon meeting a condition..
    for example the code snippet is:
    if(true){
    // I want to call js confirmRemove() over here. And get the value of variable "answer" in this if block.
    <html>
    <head>
    <script type="text/javascript">
    function confirmRemove() {
         var answer = confirm("Are you sure you want to Delete?")
    </script>
    </head>
    <body>
    <form>...

    Hi,
    Back in 2003 I have used an Applet which contain java code and this java code was calling the java scripts ( different methods, DHTML etc..)
    There was a component developed by NetScape called JSObject I am not sure it there is other third party component other then the JSObject
    look at this article which shows how (based on JSObject)
    [http://java.sun.com/products/plugin/1.3/docs/jsobject.html|http://java.sun.com/products/plugin/1.3/docs/jsobject.html]
    Regards,
    Alan Meio
    London,UK

  • Problem when connecting locally to Oracle Database 10g from Java code

    Good afternoon,
    I try to connect to my local Oracle 10g from JAVA code. Could somebody tells me what are the 'values' to enter in place of 'value1, value2, value3' in the following:
    final String connectionURLThin = "jdbc:oracle:thin:@value1:value2:value3";
    I tried to put my 'user' and 'pw' credentials I used when connecting with SQL*PLUS:
    value1=my_user_name
    value2=my_pw
    value3=my_schema
    but it doest work. Besides where could have I to put the 'WORKSPACE" name?
    Thanks for any help.
    Claude
    Details:
    ERR MESSAGE----------------------
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/dms/instrument/ExecutionContextForJDBC
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:365)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:854)
    at java.sql.DriverManager.getConnection(DriverManager.java:620)
    at java.sql.DriverManager.getConnection(DriverManager.java:200)
    at javaapplication6.ConnectionExample.driverManager(ConnectionExample.java:138)
    at javaapplication6.Main.main(Main.java:36)
    Caused by: java.lang.ClassNotFoundException: oracle.dms.instrument.ExecutionContextForJDBC
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
    ... 8 more
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)
    ---------------------ERR MESSAGE
    JAVA code------------------it compiles but throw an error when running there -> (*)...
    final String driverClass = "oracle.jdbc.driver.OracleDriver";
    final String connectionURLThin = "jdbc:oracle:thin:@jeffreyh3:1521:CUSTDB";
    final String userID = "scott";
    final String userPassword = "tiger";
    final String queryString = "SELECT" +
    " user " +
    " , TO_CHAR(sysdate, 'DD-MON-YYYY HH24:MI:SS') " +
    "FROM dual";
    public void driverManager() {
    Connection con = null;
    Statement stmt = null;
    ResultSet rset = null;
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection(connectionURLThin, userID, userPassword); // (*) prob here
    stmt = con.createStatement ();
    rset = stmt.executeQuery(queryString);
    rset.close();
    stmt.close();
    } catch (SQLException e) {e.printStackTrace();
    --------------------JAVA JDK 1.6
    My system ------------------------
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production

    Yes, the network connection could not be established. Like the error said.
    What you're asking about is the exact reason, but that could be any number of things and not at all related to code. You could have the wrong host, the wrong port. A firewall could be blocking the outgoing connection, a firewall could be blocking the incoming connection. Etc. etc.

  • Executing a DDL statement from java code

    Hi all,
    this is code from jdev11.1.1.3 version. I am trying to execute a DDL statement in oracle db from java code, but "ORA-00900: invalid SQL statement" error is coming.
    I am trying to create a table in same schema in same db by using 'Copy' command.
    Same DDL command is executing from sql command prompt & table is being created. Plz help me , as how to do from java?
            public String cmb_action() {
            // Add event code here...
            try {
                //getting source db connection
                InitialContext initialContext = new InitialContext();
                DataSource ds = (DataSource) initialContext.lookup("java:comp/env/jdbc/SourceConnDS");
                Connection sourceconn = ds.getConnection();
                sourceconn.setAutoCommit(false);
                String sql = "Copy from myschema/mypass@DB insert t_dept using select * from dept;"                       
                Statement stat = sourceconn.createStatement();
                stat.executeUpdate(sql);
                sourceconn.commit();
                System.out.println("done");
              catch (Exception ne) {
                // TODO: Add catch code
                ne.printStackTrace();
            return null;
        }

    I have a requirement to transfer data from one db to another db from Java Application Layer.Maybe, maye not. We get all sorts of weird "requirements" - which are nothing but thoughts or proposed solutions.
    But,
    Did the "requirement" mention whether the table existed already or not in the target database? - If not, did it tell you to create it - drop/create it?
    Did the "requirement" deliver some explanation to why this copying was neeeded? - Are we talking replication? - Or a one time cloning?
    Etc, etc,
    Personally I would always argue against a "reuirement" like that. - It just isn't the way to do it. Period.
    Regards
    Peter
    P.S: If you are satisfied with what COPY does, then you could let Java make an OS call and do it from there?

  • Clear the Filter Criteria from java code programmatically

    Hi All,
    I am using jdev version 11.1.1.6.0.
    I do have ADF table for which I have added filter to each column .
    I created table using java class data control.
    Filter is working Fine .
    My use case is-
    When I click on search button data is populated in table.
    When anybody enters filter value in column suppose product and hit enter ,it filters data.
    if he clears and do not hit enter key and search again then it does not show all data it only show filtered data.
    So how can I programmatically clear all filters so on click of  search it will show all the values not filtered values.
    I have not used default Filter Behavior.
    Please check below code for reference
      <af:table value="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSet}"
                                  var="row"
                                  rows="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSize}"
                                  emptyText="#{bindings.AfMyAccOrderStatusHistorySearchVO.viewable ? 'No data to display.' : 'Access Denied.'}"
                                  fetchSize="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSize}"
                                  rowBandingInterval="0" id="tblStatusHistoryList"
                                  autoHeightRows="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSize}"
                                  rowSelection="single"      
                                  width="100%"
                                  partialTriggers="::cb5 ::cb8 ::cb1 ::cb2"
                                  filterModel="#{bindings.AfMyAccOrderStatusHistorySearchVO1Query.queryDescriptor}"
                                  queryListener="#{bindings.AfMyAccOrderStatusHistorySearchVO1Query.processQuery}"
                                  filterVisible="true" varStatus="vs"
                                  binding="#{AfMyAccOrderStatusHistoryAction.orderStatusHistorySearchList}">
    <af:column headerText="#{alfaprojectBundle['ordstatushistory.column.invoiceDate']}"
                                      width="70"
                                      sortProperty="invoiceDate"
                                      sortable="true" filterable="true"
                                      id="c7" filterFeatures="caseInsensitive">
                              <af:outputText value="#{row.invoiceDate}" id="ot16"/>
                            </af:column>                     
                            <af:column headerText="#{alfaprojectBundle['ordstatushistory.column.soldto']}"
                                       width="100"   
                                       sortProperty="soldTo"
                                       sortable="true" filterable="true"
                                       id="c14" filterFeatures="caseInsensitive">
                              <af:outputText value="#{row.soldTo}"
                                             visible="#{row.visibilityIsOrdrFirstItem}"
                                             id="ot23"/>
                            </af:column>
    So how to clear all filter values from java code.

    I can't get the example "Programmatically Manipulating a Table's QBE Filter Fields"
    Where is it ?
    https://smuenchadf.samplecode.oracle.com/samples/ClearTableColumnFilterFields.zip
    Thks

  • Accessing XI Tables (ABAP Stack) from Java code

    Hi,
    IS it possible to access tables like SXMSPMAST, SXMSPEMAS directly from Java code without the use of any RFC or BAPI in between?
    Cheers,
    Earlence

    I think it is technically possible, as you can get access to the JDBC Connector service using J2EE's JNDI feature ... Then you can use the internal DB datasource to read data from tables (read ONLY, cuz I'm not sure it is a good idea to update data "outside" the box, and reading can also have potiential perf or stability issue) ... Some (better) methods can also exist !
    Chris
    Edited by: Christophe PFERTZEL on Jan 15, 2010 3:07 PM

  • Create web service from java code in Jdeveloper 11.1.1.5

    I am try to create web service from java code by default it is connected to Integrated web logic server and generate a
    WSDL like this.
    http://localhost:7101/javaexcel-project1-context-root/MyWebService1Soap12HttpPort.
    please tell me how we can change this local host to our needed Host and how to deploy this web service to web logic server.

    Hi,
    Just right click on your project and deploy it to your application server (Weblogic Server (Not the Integrated server)). {Before that, you have create your Application server connection in the Jdeveloper).
    After deployment open the Admin console of the weblogic server and find your ear of the project.Click on that (Go to the "Testing tab") and you will get the "WSDL" (Concreate wsdl)  and "Test Client" of the Project.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • How to get the CanGoBack property and GoBack() method for windows 8 store app

    Hi Everybody,         I m working windows 8 store app with webview. Here I have two buttons for go back and go forward. But i didn't have default  property for goback and goforward. How can i achieve this? 

  • Designer 10.1.2.02: failed using batch design capture

    Hi, running Oracle 10g on Solaris server release 9, and Designer on Windows XP SP1. I tried to capture the current database model but it always failed with a windows error. The report contains the following data: AppName: dwzrun61.exe     AppVer: 101

  • HT202157 Apple TV-movie rentals option.

    I don't know why every weekend, that I decide to rent a movie on Apple TV, the connection is not complete. I can see my purchased movies and TV shows. However, it is extremely frustrating, that I cannot connect to new movies to rent. I don't get this

  • Dualbooting XP and Arch

    Hi! I just finished setting up my Arch Linux in Vbox.. and im  feeling brave enough to dual boot it on my Windows PC.. I read the wiki and it seems simple enough.. but I just have a few questions.. Im going to do it in this method since this is how I

  • Updating iOS 6 without upgrading to 7

    Hi All, I have an iPhone 4s and have zero interest in iOS 7 due to the storage requirements. I saw that a new update went live for iOS 6, but when checking my settings the only update available is a full jump to iOS 7. Is there any way around this so