Executing a .class file

Hi all,
Can anyone help me about how to execute a ".class" file from within a java Program. Thanks in advance
Regards,
Deepan

i have a class file in "c:\sample.class" i want to
run this class file from my program. How to achieve
this? i am a newbie kindly bear with me..the reason you're not getting a straightforward answer is that this is the sort of thing you can find out for yourself in the tutorials, or from your teacher, or a book, or a simple google query. the forum isn't the place for complete novices to learn from, that would be a waste of effort on everybody's part
get reading!

Similar Messages

  • When i executed this class file  i am getting runtime errors

    when i executed this class file i am getting runtime errors
    code is :
    import java.awt.event.*;
    import java.awt.*;
    public class Test extends Frame
    java.awt.Window w;
         TextField t;
         Test()
         t=new TextField(20);
         add(t);
         addWindowListener(new WindowAdapter()
                             public void windowDeactivated(WindowEvent ev)                               {                    
                                  w.toFront();          
                                  System.out.println("hai");
         setSize(300,300);
         setVisible(true);
    public static void main(String args[])
    Test t =new Test();
    after executing that class i am getting this errors
    Exception occurred during event dispatching:
    java.lang.NullPointerException:
    at WindowEventDemo.windowActivated(WindowEventDemo.java:76)
    at java.awt.Window.processWindowEvent(Window.java:612)
    at java.awt.Window.processEvent(Window.java:576)
    at java.awt.Component.dispatchEventImpl(Compiled Code)
    at java.awt.Container.dispatchEventImpl(Compiled Code)
    at java.awt.Window.dispatchEventImpl(Compiled Code)
    at java.awt.Component.dispatchEvent(Compiled Code)
    at java.awt.EventQueue.dispatchEvent(Compiled Code)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:68)
    if anybody know how to pls help me

    You are using w that you have not done anything with.
    Add following code to the begining of your cinstructor:
    w = this;
    Then it should work.
    //Anders ;-D

  • I created a class file , if i execute this class file it has to be always o

    i created a class file , if i execute this class file it has to be always on top if i open any other programms or applications then also this class file application has to show me on the screen top , i meas ti has to show me first and behind all applications which i opend other applications
    How to do this please help me
    bhaskar

    It sounds like you might be able to write a .bat script to run the application, create a desktop icon for that and set its properties so it runs in the background.

  • Can you execute a class file without invoking the command line java command

    I am running java on a Windows XP equipped machine, and I am wondering if it is possible to execute a class file by double clicking the file icon, or can it only be done via command line. So far I have been unsuccessful in my attempts - I tried associating the class file with the java executable in my JRE directory, but that didn't work.
    Many thanks,
    -Stile

    nope, can't be done, by design... microsoft recognised java as threat to the empire very early on in the peace.... but you can write a batch file to execute myprogram.class called myprogram.bat and stick it in your PATH.
    keith.

  • Executing java.class files

    From julesh1
    To whom may help me:
    I'm new to java.
    I'm currently using jdk1.4.
    I can compile File.java just fine.
    But when i try to execute File.class i get an error message saying
    java.lang.noclassDefFoundError.
    This did not happen before.
    any help would greatly be appreciated.

    when you receive that error it usually indicates that the CLASSPATH does not include the directory where you are saving your .class files. If you are using Windows 2000, you need to:
    1. Right click on My Computer
    2. Go to properties
    3. Click on the Advance tab
    4. Click on Environment Variables
    5. Edit or create a new variable named ClassPath and type in something similar to this:
    .;C:\java;C:\jdk1.3.1;
    If you have Windows 95 or 98,
    Click on Start, then Run and type in sysedit, then click OK.
    Go to the AUTOEXEC.BAT file which usually is the first file to pop up. Type:
    SET CLASSPATH=.;C:\jdk1.3.1\classes;c:\java
    In the above . is the current directory; c:\jdk1.3.1\classes is a place where you can store your class files; c:\java is a directory I created on my hard drive where I store my class files..
    I hope this helps,
    Kent

  • Execute Class file

    Is is possible execute the class file without the intepreter?
    If can , how to do?
    Can I convert the class file to exe file ?

    Is is possible execute the class file without the
    intepreter?No, only if you run on a platform that understands the java bytecodes without an interpreter.
    Can I convert the class file to exe file ?Yes, search for java exe(cutable) in the forum or the web. You need a program to do this conversion, but then your program will only run on windows.

  • Executing .CLASS file

    Hello,
    I recently had my machine reimaged and I'm trying to configure it to execute Java class files from the command prompt. After manipulating the PATH and CLASSPATH system variables I was able to get it to the point where I can compile .JAVA source code, but I still can't execute the file.
    The source is named NotesExport.java. I can issue the javac NotesExport.java command successfully, but when I issue java NotesExport, it gives the following error:
    Can't find class NotesExport
    I've confirmed that the NotesExport.class file is indeed there so I'm confused as to why it can't be found.
    Does anyone know what's wrong here?

    Yes, the problem is with the import line below:
    import lotus.notes.*;
    public final class NotesExport extends NotesThread{ <rest of code> }I was told that in order for the import command above to work, I need to add the path to the notes.jar file in my classpath (c:\notes\notes.jar). I've done that, but it still doesn't work. I get the following error messages when I compile this code in JCreator:
    --------------------Configuration: JDK version 1.1.8 <Default>--------------------
    C:\SasJava\NotesExport.java:9: Package lotus.notes not found in import.
    import lotus.notes.*;
           ^
    C:\SasJava\NotesExport.java:11: Superclass NotesThread of class NotesExport not found.
    public final class NotesExport extends NotesThread{
                                           ^
    2 errors
    Process completed.I'm assuming that the NotesThread class is bundled into that notes.jar file, but I'm not sure. I'm also not sure what that lotus.notes.* is all about... I figured that package was part of the notes.jar file too. Since it apparently isn't finding the notes.jar file, even though I tell it where it is in my CLASSPATH, nothing is working!

  • Unable to Execute Class File

    Dear All,
    I am Using JDK1.3 in Microsoft Windows 2003 sever.
    I had Created a test program as follows, Which is Saved in the BIN directory Named t.Java
    class t
    public static void main (String arg[])
    {     System.out.println ("Test Prorgram ");     }
    When I compile the above Code it Compiled Successfully.
    But, When I try to execute the class
    It reports the ClassNoDefFoundException.
    It had Try the following Set Classpath = C:\jdk1.3\bin; command, still I have the same problem.
    How can I Execute the Class File.?

    Run it like this:
    java -classpath . tSome useful resource:
    Java's code conventions: [http://java.sun.com/docs/codeconv/]
    What is the classpath really: [http://en.wikipedia.org/wiki/Classpath_(Java)]
    Also, Java 1.3 is really old. I recommend to download and install Java 1.5 or 1.6.

  • Executing class files from a Java App dynamically

    Hi!, Is there any way i can execute java .class files from my Java Application dynamically. I know that java uses Dynamic method Invocation. Is that true of class files generated using some other language compiled for the JVM.
    In my case i would like to make a Web browser that interprets HTML and also java applets embeded in them. I would like to use the JRE of the platform execute the applets for me rather than writing the code for my Browser to interpret the class files.
    Thanks in Advance.

    You just need a custom class loader to bring these applets into your JVM.
    http://developer.java.sun.com/developer/onlineTraining/Security/Fundamentals/magercises/URLClassLoader/index.html
    Then you can use the methods of java.lang.Class to create an instance of such a class. As soon as you have it, you can just treat it as a regular Applet and invoke init(), stop() etc. appropriately.
    If you want to execute anything else than conventional Applets, you might consider reflection to find out about methods implemented:
    http://java.sun.com/docs/books/tutorial/reflect/index.html

  • How to execute a jar file which has an applet, without using a html file ?

    I have a jar file which contains a set of class files. iam able to execute the jar file by using this html code
    <html>
    <applet code="file.class" archive="file.jar" width="500" height="300">
    <param name="name" value="value">
    </applet>
    </html>
    I want to know how to execute this class file without using the html tags.
    pls help me out in this.
    Anki

    Hi,
    You can make an executable jar file such that when you double click on that it starts running. Just follow the steps.
    1. Open a notepad and write the following
    Main-Class: XXXXXXXX
    XXXXXXX means Your Main Class name. Don't forget to press Enter after you write your class name.
    2. Save the file as Mani.mf
    3. In the commant prompt ( your directory ) type following lines.
    jar cmf Mani.mf Demo.jar *.*
    4. This will make a jar file which is executable jar file
    Hope this will help you.
    Deepak

  • How to get *.class file path....

    how could find the executable file path at execution time..
    if there is one *.class file, then i will paste it to another location . next i will execute that .class file. how to find that path from execution program ....

    Try the following
    URL path = getClass().getProtectionDomain().getCodeSource().getLocation();

  • Can i give a process name of executing java class

    hi all,
    what i need is when i execute the class file using java at the command prompt i want to create a separate process of that class. that means when i execute this class i want 2 processes running one is "java" and the other is "The Class To be executed".
    is it possible????
    actually my requirement is that i want only one instance of my class can run at a time.
    please help me
    thanks
    bye

    hi
    actually i can not use the file lock because my application is going to run on Solaris machine and since its a mutiuser platform and every user has a limited access to his data.and any user can run my application so the problem is where one user will write into a file so that other user can also read from the same file.
    can i do it other way using native methods if yes can u elaborate please
    thanks
    bye

  • Java.exe does not execute the clas file ????

    I would like to know how to run a compiled program in Java, for example HELLOWORLD.CLASS after I have changed it from a .java file into a .class file.
    What can I do to execute this .class file to see how
    the program works ?

    You should start with:
    java HelloWorldRemember that it is case sensitive. There are several other things that can go wrong so keep posting your trials and errors!

  • Error when trying to execute .class file.

    Hello,
    I downloaded jdk 1.5 from the official java website and have installed it properly. I tried compyling my java program and it gets compilde. But when I try to execute it I keep getting the error "Exception in thread "main" java.lang.NoClassDef Found Error". Please help me .........

    It's because java can't find one (or more) of your .class files. You have to tell it by passing the correct classpath to java.exe.
    Read about the classpath and java launcher here:
    http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html
    http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/java.html
    Message was edited by:
    Loko
    Because:
    Something is definitely wrong with the formatting

  • Executing class files

    Pls help I got following error while executing class file.
    Exception in thread main java.lang.NoClassDefFoundError : main
    Edited by: Mubin_Attar on May 19, 2008 6:34 PM

    Mubin_Attar wrote:
    Pls help I got following error while executing class file.
    Exception in thread main java.lang.NoClassDefFoundError : main
    Edited by: Mubin_Attar on May 19, 2008 6:34 PMIt appears that you typed "java main" or something like that, which means you have a file named "main.class". This is telling you that you don't have such a file.

Maybe you are looking for

  • Error Message: Need to purge Cache in Adobe Bridge CC (on PC)

    I tried purging using Adobe Bridge by going to Edit/Preferences/Cache then purging, but it becomes non responsive.  The error message said the problem files were at Users/(my user name)/AppData/Roaming/Adobe/BridgeCC/Cache.   There are 4 files in the

  • Has stopped providing A/V warning on launch

    Whenever I opened FCE 4.0, the A/V warning would show up (as I had instructed it to by NOT checking "Do Not Show.." in User Settings. But now, without any changes that I am aware of, when I open it just goes to the project I am working on (as it did

  • Getting the no. of rows returned from the resultset

    Could somebody tell how can I get the count of rows from the resultset object. Thanks a lot in advance

  • Query regarding RF in warehouse manegment

    Dear Gurus,      Can we use more then 6 sequence nombers while  Defining menu manegment in WM . If yes how. Pls guide me.

  • Various transparency issues with conky.

    So, I have some ring graphs for a bunch of things, they are all semi-transparent and they look pretty darn good, but the text I use is unreadable because of my background having multiple colors. Well, after reading the conky config settings page I de