Launching Class File with URLClass Loader

Before anyone flames me I want toe explain that I have searched the forums and the deveolper section and though I have found a lot of useful information I am still not sure what I am missing. It may be something small that I am just over looking so if someone could look over my code I would greatly appreciate it.
I am making a class with a URLClassLoader with which I can launch another java class file. At this stage the class merely takes the path to the file and the name of the class file as command line arguements. This attempt was just a test so I could implement it into another application. The code itself was almost taken completely from a trial on the developer part of this site. The issue I am running into is that nothing appears to launch. I can run the app from the command line and pass the arguements, however the class file I pass never appears to launch. I do not receive any errors at all. Any ideas what I am missing or doing wrong?
import java.net.*;
import java.io.*;
public class Launcher
     public static void main(String args[])
          try
               File daPath = new File(args[0]);
               System.out.println(daPath.toString()); //output
               URL daPathURL[] = {daPath.toURL()};
               ClassLoader daLoader = new URLClassLoader(daPathURL);
               Class daClass = daLoader.loadClass(args[1]);
               System.out.println("loaded " + daClass.toString()); //output
               Object daObj = daClass.newInstance();
               System.out.println("new instance"); //output
          }catch(MalformedURLException e){
               e.printStackTrace();                    
          }catch(ClassNotFoundException e){
               e.printStackTrace();
          }catch(InstantiationException e){
               e.printStackTrace();
          }catch(IllegalAccessException e){
               e.printStackTrace();
}

Are we talking about a new main class here with an main method.
To run such a class you don't instaciate it (it does that itself). You need to load the class then invoke the main method.
Something like:
String[] otherArgs = String[args.length - 2]; // copy args except first two
System.arrayCopy(args, 2, otherArgs, 0, args.lenght - 2];
Method mainMethod = dClass.getMethod("main", new Class[]{String[].class});
mainMethod.invoke(null, new Object[]{otherArgs});

Similar Messages

  • Class file cannot be loaded.

    I wrote an applet code and tested it in appletviewer. It's fine. But the class file cannot be loaded into the browser. Please tell me how to fix it.
    I appreciate any help.

    Couple small errors. You have a close bracket instead of a close parens after "Hello" and most importantly, you are missing a few steps. Here is one solution.
    import javax.swing.JApplet;
    import java.awt.Graphics;
    public class Test extends JApplet{
         public void paint(Graphics g)
              g.drawString("Hello", 25, 25);
    I imported the swing and awt packages. This allowed the call to graphics. I also replaced the close bracket with a close parens.
    You almost had it. The HTML you supplied is correct.

  • Problem with loading file with SQL loader

    i am getting a problem with loading a file with SQL loader. The loading is getting
    terminated after around 2000 rows whereas there are around 2700000 rows in the file.
    The file is like
    919879086475,11/17/2004,11/20/2004
    919879698625,11/17/2004,11/17/2004
    919879698628,11/17/2004,11/17/2004
    the control file, i am using is like:-
    load data
    infile 'c:\ran\temp\pps_fc.txt'
              into table bm_05oct06
    fields terminated by ","
    (mobile_no, fcal, frdate )
    I hope, my question is clear. Please help, in solving the doubt.
    regards.

    So which thread is telling the truth?
    Doubt with SQL loader file wih spaces
    Are the fields delimited with spaces or with commas?
    Perhaps they are a mixture of delimiters and that is where the error is coming in?

  • Using class files with applets

    I've converted a college project, a calculator, into an applet for a website resume. When the html file that loads the applet is opened on a machine with a JVM, the applet works fine. When I tested it on a machine that doesn't have a JVM, the applet wouldn't open.
    I'm assuming its because I'm using methods from classes such java.math, java.awt and java.awt.event. I wanted to try to include the neccessary class files into a .jar file that could be included into the archive attribute. Would this work? and also, where can I actually find these files so that I can put them into a jar file. For example, which directories would I look at to find them? I'm on Mac OS 10.3.7.
    Even with a search utility,I can't find the specific files with I'm looking for.
    Any help is greatly appreciated

    Hi,
    It doesn't matter that you have used classes in the packages java.math etc. The application will never run if there isn't a JRE installed for the web browser. I think most people usually puts a script on the html page which detects if a JRE is installed, and directs users to the download page if there is no JRE.
    Kaj

  • CF Class Files Won't Load

    I've tried just about every variation I can to get the CF class files (e.g. CFSlider, CFGrid, etc.) to work.  I've check the class path and have tried both the cfapplet.jar and removing the class files to see if I could get the system to recognize them.  When the applet attempts to load I'm getting the following error:
    java.lang.ClassFormatError: Incompatible magic value 1013478509 in class file coldfusion/applets/CFSliderApplet
    My understanding of that error is that it can't find the applet.  At one point I placed the cfapplet.jar file in the lib directory because I knew it would at least recognize it there without any confusion.  At first another exception occurred in my application output because the jar file contained more than one path within it and ColdFusion wasn't happy about the difference in signature.  So I removed the files in question from the jar file and it was happy again, but it still wouldn't load the applets.
    I did try creating a coldfusion/applets directory just to see if I could fool it into finding it since the java file has a package path of coldfusion.applets, but nothing is working.  Shouldn't be this difficult so I'm trying to figure out what I've overlooked.
    Any assistance would be appreciated.  I'm wondering if the classes that come with CF are worth all the effort, but I would like to at least see them working.
    Thanks.

    CF: 7,0,1,116466  Ent OSVer 5.2
    OS: Win 2003
    JVM: C:/j2sdk1.4.2_12/jre AND 1.4.2_09  (a second server)
    Standard installation on a single server.
    Thanks!

  • Loading huge file with Sql-Loader from Java

    Hi,
    I have a csv file with aprox. 3 and a half million records.
    I load this data with sqlldr from within java like this:
               String command = "sqlldr userid=" + user + "/" + pass
                        + "@" + service + " control='" + ctlFile + "'";
                System.out.println(command);
                if (System.getProperty("os.name").contains("Windows")) {
                    p = Runtime.getRuntime().exec("cmd /C " + command);
                } else {
                    p = Runtime.getRuntime().exec("sh -c " + command);
                }it does what I want to, load the data to a certain table, BUT it takes too much time, Is there a faster way to load data to an oracle db from within java?
    Thanks, any advice is very welcome

    Have your DBA work on this issue - they can monitor and check performance of SQL*Loader
    SQL*Loader performance tips          [Document 28631.1]
    SQL*LOADER SLOW PERFORMANCE          [Document 1026145.6]
    Master Note for SQL*Loader          [Document 1264730.1]
    HTH
    Srini

  • Loading multiple files with SQL Loader

    Hello.
    I will appreciate your recommendation about the way to load multiple files (to multiple tables) using SQL Loader with only one Control file.
    file1 to load to Table1, file2 to load to Table2 etc.
    How the Control file should look like?
    I was looking on Web, but didn't find exactly what I need.
    Thanks!

    Ctl File : myctl.ctl
    ---------- Start ---------
    LOAD DATA
    INFILE 'F:\sqlldr\abc1.dat'
    INFILE 'F:\sqlldr\abc2.dat'
    INTO TABLE hdfc1
    (TRANS_DATE CHAR,
    NARRATION CHAR,
    VALUE_DATE CHAR,
    DEBIT_AMOUNT INTEGER,
    CREDIT_AMOUNT INTEGER,
    CHQ_REF_NUMBER CHAR,
    CLOSING_BALANCE CHAR)
    INTO TABLE hdfc2
    (TRANS_DATE CHAR,
    NARRATION CHAR,
    VALUE_DATE CHAR,
    DEBIT_AMOUNT INTEGER,
    CREDIT_AMOUNT INTEGER,
    CHQ_REF_NUMBER CHAR,
    CLOSING_BALANCE CHAR)
    -----------End-----------
    Sqlldr Command
    sqlldr scott/tiger@dbtalk control=F:\sqlldr\myctl.ctl log=F:\sqlldr\ddl_file1.txt
    Regards,
    Abu

  • Se development kit (jdk 6) problem creating class file with HelloWorldApp

    I downloaded the java SE Development kit (JDK 6) with Java FX SDK and used the download manager from Java web site, the program downloaded the
    jdk-6u13-javafx-1_1_1-windows-i586 icon to my desktop and the java program to
    C\Program Files\Java\jdk1.6.0_13
         Jre1.5.0_05
         Jre1.6.0_03
         Jre6
    I then created a Java source file which was HelloWorldApp.java. and typed in the Hello World Code as requested I saved it to
    C\Documents and Settings\Compaq_owner\Java.
    Then I try to compile my source file into a .class file and get stuck as I am told to open a command window which I do through, start\allprograms\accessories\command promt.
    My command window says C:\Documents and Setting\Compaq_Owner>
    I am told to compile my source file and I must change my directory in the command window to the directory where my file is located.
    I type after the existing promt, cd C:\java and also tried, cd C:\Documents and Settings\Compaq_Owner\Java\HelloWorldApp. And was told both times the system cannot find the path specified
    I typed dir after the promt and can see the java directory there in the list, but have I placed my HelloWorldApp File in the wrong place what is wrong please help I cannot get off the ground
    Kind regards pete

    petefizz wrote:
    I then created a Java source file which was HelloWorldApp.java. and typed in the Hello World Code as requested I saved it to
    C\Documents and Settings\Compaq_owner\Java.Then the full path to your HelloWorldApp.java file is: C\Documents and Settings\Compaq_owner\Java\HelloWorldApp.java.
    Then I try to compile my source file into a .class file and get stuck as I am told to open a command window which I do through, start\allprograms\accessories\command promt.
    My command window says C:\Documents and Setting\Compaq_Owner>
    I am told to compile my source file and I must change my directory in the command window to the directory where my file is located. You file is located in the directory, C\Documents and Settings\Compaq_owner\Java
    I type after the existing promt, cd C:\java and also tried, cd C:\Documents and Settings\Compaq_Owner\Java\HelloWorldApp. And was told both times the system cannot find the path specifiedcd stands for Change Directory. You want to change to the directory where your .java file is. You can not use a path that ends in a file because a file is not a directory.
    You may need to put C\Documents and Settings\Compaq_owner\Java inside double quotes, "C\Documents and Settings\Compaq_owner\Java" I think newer versions of Windows will not require the double quotes.

  • .class Files with "$X" extensions

    Hi everybody,
    when I deploy my App, some confusing .class files are generated by my JDev (10.1.3.3) ...
    In my Project I declare a Class named
    - JClientDesktopManager.java
    This is compiled to two .class files:
    - JClientDesktopManager.class     
    - JClientDesktopManager$1.class
    Whats that strange class with "$1"?
    Should I care about about it? - it seems randomly...

    Hi!
    Theses files house anonymous inner classes, a standard Java mechanism.
    Whenever you write something like:
    ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { <your code here> }};or
    JTable table = new JTable() { public boolean isEnabled() { <your code here> }};you create in fact new (anonymous) inner classes. These classes have no name (hence "anonymous"), they are just numbered.
    For more background you could just Google for "anonymous inner class".
    Sascha

  • Package class files with bpel suitcase

    Hello,
    Is it possible to package java classes which are invoked through WSIF along with the BPEL Suitcase generated by bpelc?
    I've noticed that when generating and deploying the suitcase using JDeveloper (10.1.3.x) - the class files are compiled to the output directory and packaged in the suitcase, but when I run the same build.xml via Ant (ant deploy-process), the class files are missing in the output directory and thus missing in the suitcase.
    I'm using BPEL 10.1.3.
    So, the question is what causes the difference and how can I achieve packaging the class files using Ant without Jdeveloper.
    Any help is most appreciated.
    Best regards,
    Harm

    Well, I found the answer myself after decompiling com.collaxa.cube.ant.taskdefs.Bpelc.class..... because documentation or manuals about the ant tasks where not available.
    Apparently, the bpelc tasks can have nested elements of type zipfileset. (See the Ant documentation about this type). In here is the solution.
    Here is a how-to:
    You have to change the jdeveloper generated build.xml.
    @ 1st you have to add a "javac" task (if not already there) like below, and add it to build.xml:
    <target name="java-compile" description="Compile Java source files">
    <echo>
    | Compiling java source files
    </echo>
    <javac destdir="${process.dir}/output"
    encoding="UTF-8" source="1.5" target="1.5">
    <src path="src"/>
    </javac>@ 2 Extend target "process-deploy" to depend it on target "java-compile". It is important that the java gets compiled before the bpelc is executed. Like so:
    <target name="process-deploy"
    depends="validateTask, java-compile, compile, deployProcess, deployTaskForm, deployDecisionServices" />@ 3 Change the bpelc task by including a nested classes element that includes your class files, like so:
    <bpelc input="${process.dir}/bpel/bpel.xml" out="${process.dir}/output"
    rev="${rev}" home="${bpel.home}">
    <classes dir="${process.dir}/output" includes="**/*.class"/>
    </bpelc>When you run target "process-deploy", the class files are added to the bpel suitcase.
    Harm

  • Two class files with $ on compile

    Hello friends, I have a simple java program, that consists of two classes, coded in the the same java file.
    One of hte classes extends Thread.
    When I compile the source file, I get one class file for the base class, and two for the other one - ClassName.class and ClassName$1.class.
    Why is the second one created?

    The ClassName$1.class is a class file for an anonymous inner class. You create them with code likebutton.addActionListener(new ActionListener() {
         actionPerformed(ActionEvent ae) {
              System.out.println("button was pressed");
    });This particular example is from the GUI world where event listeners are commonly created using anonymous inner classes. There's a separate file for it just because there's always exactly one class file for each class.

  • SQLPLUS: How to verify that java class file have been loaded

    Hi All,
    I just loaded my Java class file using CREATE OR REPLACE JAVA.
    Java was created sucessfuly, but how can I check or find out if my file have been loaded correctly.
    I also found a command :
    SQL>exec myjava.showobjects
    but i don't have the loadjava utility install....is there any command from SQL PLUS?
    thanks

    Thanks for the sql command....after that query what do I do next to see if for example tree.class is in the dba_object.
    Sorry, I am a newbie and the question may be a bit generic .....

  • Launching swf files with Director

    I recently obtained Adobe Director 11.5 to create a menu for launching a series of Flash CS4 files.  I worked through Dean Utian’s excellent tutorial and found the following script to program a button to launch another Director file.  However, I can’t figure out how to get it to launch a swf file.  If someone could tell this poor soul how to get Director to launch swf files I would really appreciate it.  Thatch
    on mouseUp me    
      play movie "FileName”      
    end

    I don’t know if anyone else will ever need to do this, but just in case I thought I should share the final protocol we developed.  This will embed a Flash SWF file into a Director DIR, so it can be published in a form that can be opened directly, without the multiple clicks required to open an swf with Windows Explorer (or the MAC equivalent).  It has been tested with Director 11.5 and Flash CS4.  I hope my shorthand is clear.  Dean Utian, Sean Wilson and James Newton all helped me with this, and support their support was far above and beyond the call of duty. 
    1.) Resize the Director stage to match the Flash stage
    Click the Director stage > Windows > Property Inspector > Stage Size > 550 x 400
    (alternatively you can compose the Flash file with a stage that matches Director’s.   640 x 480 is the default)
    2.) Embed the SWF into Director
    File > Import > Browse to File > Import
    Drag cast member from cast window to stage
    ctrlK > distribute horizontal across stage > distribute vertical across stage
    3.) Type a pause script into the script channel of the score
    on exitFrame
      go to the frame
    end
    4.) Open the movie script window (Ctrl + Shift + U) and type in stretcher script (this allows the SWF cast member to resize if the final window is maximized)
    on resizeWindow
      aw = _player.activeWindow
      awRect = aw.rect
      aw.drawRect = awRect.offset(-awRect.left, -awRect.top)
    end
    on zoomWindow
      resizeWindow()
    end
    5.) Set publication settings
    File > Publish Settings > Projector > Shockwave
                                                          > Center stage in monitor
                                         > Shockwave > Allow movie scaling
                                         > Html > Template > Shockwave Default
                                                    >  Stretch Style > Preserve Proportions
                                                    >  Stretch Position > Horizontal Align
                                                    >  Stretch Position > Vertical Align
                                                    >  Dimensions > Percentage of Browser Window
                                                    >  Width > 100
                                                    >  Width > 100
                                         > Formats > Windows Projector (Creates an exe for Windows)
                                                          > Macintosh Projector (Creates an app for MACs)
                                                          > HTML (Creates an htm and dcr for Windows or MACs)
    6.)Publish the movie
    File > Publish
    The Windows Projector will create a single exe file that can be opened by double clicking the icon.  If your SWF has addChild script, it will launch a second SWF, but the second SWF must be in the same folder as the exe. 
    The Macintosh Projector will create an app application that can be opened by double clicking the icon.  However this application actually consists of a folder with several subfolders and files.  You will not see this with the MAC file directory, but you will if you try to E-mail the application.  If your SWF has addChild script, it will launch a second SWF, but the second SWF must be in the same folder as the app.
    The HTM Projector will create a htm file and a dcr shockwave file.  Both must be in the same folder, and the user must double click the htm icon to open the dcr.  If your SWF has addChild script it will not launch a second SWF.

  • I can load an Applet .class file with an OBJECT tag...

    How can I load a .jar file? I foolishly believed I could replace "myclass.class" with "myjar.jar" in the <PARAM> tag associated with an <OBJECT> tag, and if I had created my manifest file correctly, the Main-Class in my .jar would have its init() method called upon IE load of the web-page. But alas, it is not that simple.
    Is there an incantation of the <OBJECT> tag that is appropriate for .jar files?
    Thanks in advance for any help you can provide in this area.

    Please ignore the duplication. My browser burped, and I can't seem to figure out how to delete a thread.
    See answer posted in other thread.

  • URGENT: Problems Loading files with SQL Loader into a BLOB column

    Hi friends,
    I read a lot about how to load files into blob columns, but I found errors that I can't solve.
    I've read several notes in these forums, ine of them:
    sql loader: loading external file into blob
    and tried the solutions but without good results.
    Here are some of my tests:
    With this .ctl:
    LOAD DATA
    INFILE *
    INTO TABLE mytable
    REPLACE
    FIELDS TERMINATED BY ','
    number1 INTEGER EXTERNAL,
    cad1 CHAR(250),
    image1 LOBFILE(cad1) TERMINATED BY EOF
    BEGINDATA
    1153,/opt/oracle/appl/myapp/1.0.0/img/1153.JPG,
    the error when I execute sqlldr is:
    SQL*Loader-350: Syntax error at line 9.
    Expecting "," or ")", found "LOBFILE".
    image1 LOBFILE(cad1) TERMINATED BY EOF
    ^
    What problem exists with LOBFILE ??
    (mytable of course has number1 as a NUMBER, cad1 as VARCHAR2(250) and image1 as BLOB
    I tried too with :
    LOAD DATA
    INFILE sample.dat
    INTO TABLE mytable
    FIELDS TERMINATED BY ','
    (cad1 CHAR(3),
    cad2 FILLER CHAR(30),
    image1 BFILE(CONSTANT "/opt/oracle/appl/myapp/1.0.0/img/", cad2))
    sample.dat is:
    1153,1153.JPEG,
    and error is:
    SQL*Loader-350: Syntax error at line 6.
    Expecting "," or ")", found "FILLER".
    cad2 FILLER CHAR(30),
    ^
    I tried too with a procedure, but without results...
    Any idea about this error messages?
    Thanks a lot.
    Jose L.

    > So you think that if one person put an "urgent" in the subject is screwing the problems of
    other people?
    Absolutely. As you are telling them "My posting is more important than yours and deserve faster attention and resolution than yours!".
    So what could a typical response be? Someone telling you that his posting is more important by using the phrase "VERY URGENT!". And the next poster may decide that, no, his problem is evern more import - and use "EXTREMELY URGENT!!" as the subject. And the next one then raises the stakes by claiming his problem is "CODE RED! CRITICAL. DEFCON 4. URGENT!!!!".
    Stupid, isn't it? As stupid as your instance that there is nothing wrong with your pitiful clamoring for attention to your problem by saying it is urgent.
    What does the RFC's say about a meaningful title/subject in a public forum? I trust that you know what a RFC is? After all, you claim to have used public forums on the Internet for some years now..
    The RFC on "public forums" is called The Usenet Article Format. This is what it has to say about the SUBJECT of a public posting:
    =
    The "Subject" line (formerly "Title") tells what the message is about. It should be suggestive enough of the contents of the message to enable a reader to make a decision whether to read the message based on the subject alone. If the message is submitted in response to another message (e.g., is a follow-up) the default subject should begin with the four characters "Re: ", and the "References" line is required. For follow-ups, the use of the "Summary" line is encouraged.
    =
    ([url http://www.cs.tut.fi/~jkorpela/rfc/1036.html]RFC 1036, the Usenet article format)
    Or how about [url http://www.cs.tut.fi/~jkorpela/usenet/dont.html]The seven don'ts of Usenet?
    Point 7 of the Don'ts:
    Don't try to catch attention by typing something foolish like "PLEASE HELP ME!!!! URGENT!!! I NEED YOUR HELP!!!" into the Subject line. Instead, type something informative (using normal mixed case!) that describes the subject matter.
    Please tell me that you are not too thick to understand the basic principles of netiquette, or to argue with the RFCs that governs the very fabric of the Internet.
    As for when I have an "urgent" problem? In my "real" work? I take it up with Oracle Support on Metalink by filing an iTAR/SR. As any non-idiot should do with a real-life Oracle crisis problem.
    I do not barge into a public forum like you do, jump up and down, and demand quick attention by claiming that my problem is more important and more urgent and more deserving of attention that other people's problem in the very same forum.

Maybe you are looking for

  • Looking for mobile app to access my acct away fom home.

    I just received a new smart phone and trying to set it up. Unfortunately it's not an iPhone. Is there an iTunes mobile phone app that is compatible with the Samsung Galaxy S3 (Android) and will allow me to access and play music and audio books from m

  • Trouble with ipod nano

    had ipod nano since xmas put 108 songs on xmas morning come to put new songs on today connected ipod to pc and had message saying usb devise malfunctioned unistalled and tryed again still the same message please help dad going crazy at me

  • Line In problem

    I have a basic 2.66GHz Mac Pro and i'm having problem's connecting a microphone to it. I have a analog microphone but there is no signal from it. The same microphone works on a Pc without problems... Any suggestions? Can somebody please try a mic and

  • Automatic Update of Quantity without BF ?

    When I ran a PP cycle, after confirming the production order ( C015), I was expecting to do manual Goods Reciept(MIGO/MB1C), as I didnot maintain backflushing ( neither in material master, Rtg, w/c) Now, Is there are anyother way without maintaining

  • Quick time export

    I am exporting a quick time file from my CS 6 time line. It is a straight time w/o any effects. So it goes it up till 98% of the render and it comes up with "Unknow Error" message. I have looked around the forums for this error message but haven't fi