Executing the .jar

When I type "java -jar myJarFile.jar" I have the next error:
"Exception in thread "main" java.lang.NoClassDefFoundError: myMainClass"
I have included the manifest before. What is the problem? Why cannot I execute my file by double-clicking on the Icon?
Thanks

Sorry, I made a mistake posting it, the manifest is:
Manifest-Version: 1.0
Main-Class: MyMainClass
Classpath: .\MyJar.jar
And the error is about MyMainClass, not myMainClass.
Thanks!

Similar Messages

  • Exception is thrown only while executing the jar file

    java.lang.NoClassDefFoundError: javax/mail/Address Exception is thrown only while executing the jar file. But the program compiles and executes good when executed for command prompt through the class files.
    I used javamail API in my program. Classpath and every others are set to the right one's. Executed fine when used java Random.class. But the problem is only with the jar file.
    Please help me out in this regard. Why the exception is thrown only in jar but not at class level.

    Assuming you're running your program using "java -jar", your jar file needs a Class-Path entry
    in the manifest file that references mail.jar.

  • 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 do you execute a JAR file?

    I'm sorry this is so basic, but I honestly do not know how to do this nor can I find anything online here or anywhere via Google to help me with this one.
    I have a JAR file that I created on another machine using JDK 1.6.0 and NetBeans 5.5 on WinXP.
    I copied and pasted that JAR file over to my machine at home also using JDK 1.6.0 and NetBeans 5.5 on WinXP
    I put the exact directory name where the JAR file resides, "C:\Program Files\Java\jdk1.6.0\classes", in CLASSPATH and rebooted my machine.
    However, upon CD'ing to that directory and doing "java -classpath . GUI.jar", I get a "NoClassDefFoundError" when trying to do so.
    Furthermore, I was not sure how to use NetBeans to run the JAR file to execute the classes within.
    What did I do wrong? I'm so sorry this is so basic.
    Thanx
    Phil

    You are using netbeans to build your jar. Go to your project properties (right click on the project name and choose properties). Then select "Run" from the tree. You will find a text box "Main Class" there, put the name of the class in there that has your main() method, including full package if you have one. That is WITHOUT the .class extension.
    Build your jar, it will be placed in the dist directory of your netbeans project. You can now run it from netbeans itself if you want. If ever you want to run the jar from the command line on your home machine, just navigate to the directory with the jar file and execute this:
    java -jar yourjar.jarand you're off. If your runtime environment is propertly setup you can even execute the jar by simply double clicking on it from the windows explorer. No need to change the CLASSPATH variable at all, in fact it is ignored when executing a jarred application.
    Also a note: you do not need to reboot your machine when you change an environment property. Simply change them using my computer -> properties -> advanced tab -> environmental variables. If you have any command prompts open, close and reopen them so the properties are updated properly.

  • How to get a file in the same dir with the jar-executable

    Hi,
    I need to read/write a file that exists in the same directory with the jar-executable. How can i do that? I think that when i specify no path for the file, the file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and the file are.
    Thanx in advance

    Hi,
    I need to read/write a file that exists in the same
    directory with the jar-executable. How can i do that?
    I think that when i specify no path for the file, the
    file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and
    the file are.
    Thanx in advance
    When you specify no path for the file, the file has to be in the directory where the virtual machine was started. ( the directory the java command was invoked in .)
    If you can't control the directory in which the vm is started, but you know the name of the .jar file you can do the following. This trick takes advantage of the fact that if you are using classes in a jar file, the name of the jar file must be in your classpath.
    public static String getPathOfJar( String nameOfJar )
    throws Exception
    StringTokenizer st = new StringTokenizer(
    System.getProperty( "java.class.path" ) ,
              System.getProperty( "path.separator" ) );
    String jarfile = "";
    while ( st.hasMoreTokens() )     
    String token = st.nextToken();
    if ( token.indexOf( nameOfJar ) > -1 )
    jarfile = token;
    break;
    if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
    String path = jarfile.substring( 0 , jarfile.indexOf( nameOfJar ) );
    return path;
    //To open a file in the same directory as the sun archive tools.jar
    File f = new File( getPathofJar( "tools.jar" ) + "someFile.txt" );

  • Read binary files that are wraped in the downloaded executable signed jar

    Hello, there:
    I have created a Swing application and created a signed jar file and uploaded it to my site. The signed jar includes class packages, and a folder of binary files which are the datasource for my application.
    jws downloads this signed executable jar, it'll automatically run it, but it has problems reading the binary folders wrapped in itself (the app is supposed to read the folder's structure and use the info to create a JTree object, and read the file's content as well). Is it the file path conversion problem? Do we need to use URL instead? I tried it after reading some threads on this forum but didn't make it.
    As an alternatives, I want JWS to unjar the jar file and expand it to exploded files. I manually unjar it and run the app from command line, it works fine.
    Plus, the app is supposed to manipulate the binary files when it's in process, like saving new content back to the files, zip the files and upload them to the remote sql server. therefore, I think it's easy to have it run when it's expanded.
    So here is the question: JWS by default is running the executable jar, is there a way to tell JWS to unzip the jar and find the main class in the exploded files and run it?
    Thanks a lot for your suggestions,
    Sway

    You can get to any resource in a jar file in your classpath. The code below will return InputStream for resource.bin nested two packages down.
    InputStream in = YourClass.class.getResourceAsStream("/com/mypackage/resouce.bin");  //use '/' instead of '.'You can open a FileOutputStream to write that file.
    OutputStream out = new FileOutputStream("myTempResource.bin");
    IOUtil.streamAndClose(in,out);If the resouce is a nested zip or nested jar then you can use the Java Zip utilities to unwrap the stream.

  • Opening a file (hst), executes the main jar file to open the hst file HELP

    Greetings,
    I have created a file with an extension *.hst, so in my Win XP computer, when I double click a .hst file, it should be opened in my program, which is a jar file, so during the installation I associate my program to this .hst file extension.
    After all this, when I double click this .hst file, it shows an error message that the jar file is not a vaid win32 application. I donot wish to convert my file to an .exe. Help ?
    Cheers,
    Raj

    How did you specify command line for your .hst file?
    It should be something like "java -classpath
    [youfile.jar] [youclass] %1"I have not specified command line for the .hst file.
    The .hst file is just a file that is created when my main program (jar file) saves its files., later If I double click this saved hst file, it should be opened in the main jar program.
    For the double click to work, I have created a constructor
    public hst(String hstfile)
       //code to set the file contents in the window.
    }the problem is that when I double click it says that the main jar file is not a valid win32 application, so what do I do ?
    Cheers,
    Raj

  • Updating an XML file inside the Jar executable

    Hello all!
    I would like to ask how can i update an XML file that is packaged inside my jar file?
    For intstance:
    I have a Java Application in NetBeans
    Inside a package i have constructed a custom .xml file.
    I can read from this file using
    .....getClass().getResourceAsStream("/.../file.xml")and after that using XPath for querying and works fine.
    I want to update an entry in my xml file so the jar contains now the newly updated file.
    Thanks everyone who spends his time to read this. Hope someone can help me.

    Even if it were possible, it would be a bad idea. A jar file is something you deploy. It can be really hard to manage ongoing maintenance if the thing you deploy changes after you've deployed it.
    Just create a file, in an appropriate place given the user's OS, to hold data that changes after the jar has been deployed. Your application will still be in a single jar; it's just that the application will happen to create additional content outside the jar.

  • Creating a JAR in Eclipse...can't access files in the JAR properly.

    Hi all! I'm a newbie at JAR creation, and am having troubles. I have a project that loads images from image files in my project. I can create the JAR and all, and it runs, but the buttons that have ImageIcons with those IO loaded images are blank. I've tried to include the images when creating the JAR, but it keeps acting like the images never existed. When I run the JAR and have the images separately included in the directory (instead of packing them up too), it won't work as well...UNLESS those images are put in my $HOME directory (Linux).
    Does anyone know how I can properly refer to the images that I'm trying to pack into the JAR from within the JAR? Or, is there a way for the JAR to understand where those images are supposed to be (redirect the focus from the $HOME directory to the JAR's directory)? Any help would be greatly appreciated! :)
    -Keith

    Hi,
    Can the user execute the program through explorer? In Windows Server 2003, the Users group does not have Read and Execute permissions to the command processor (Cmd.exe). 
    You could refer to the article below to resolve the issue:
    "Access is denied" error message when you run a batch job on a Windows Server 2003-based computer
    http://support.microsoft.com/kb/867466
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to execute a jar file in a java application

    Hi,
    I've already try to execute a jar file by this way :
    Runtime.getRuntime().exec(java -jar myJarFile.jar);
    But the problem is that the display doesn't launch. Normally a "JFrame" display.
    however the corresponding process is launched.
    So i would to know if there is a way to execute a Jar File without using the Runtime class.
    Is there a specific class for the Jar File?
    Thank you.
    Richard

    Create a 'manifest' file pointing to the 'main' class, jar it into the .jar file, place it onto your desktop - or whereever you can click on it, and click on it.

  • How to execute a jar file in other machine?

    Hi all,
    I am working with java. and my machine is connected to LAN.I would like to execute a jar file in my machine from a remote machine that is also connected to LAN.how should i go about doing this.Help me if somebody have a solution as i am badly in need of this.
    Regards,
    Mohan

    Hi Mohan.tkm,
    If you want it to be done in pure Java and independently of the OS of both computers, you may build a RMI server that will launch your JAR by request of a remote RMI client.
    There's an example of RMI here .

  • Embed Native Executables in JAR for later execution?

    Hi to all!
    I've the need to write a Java program, which has to execute a native executable for a specific task. The executable is available for Windows, Mac and Linux. I wanted to embed the native program into the jar archive and to execute it (differently depending on the platform) with ProcessBuilder.
    But, until now I didn't find a solution and I don't really know how to achieve this.
    The most important thing is to not have to rely on a installation process which would place the executables at a fixed place.
    Thanks in advance to everyone,
    Daniel Rampanelli

    Hi to all!
    I've the need to write a Java program, which has to execute a native executable for a specific task. The executable is available for Windows, Mac and Linux. I wanted to embed the native program into the jar archive and to execute it (differently depending on the platform) with ProcessBuilder.
    But, until now I didn't find a solution and I don't really know how to achieve this.
    The most important thing is to not have to rely on a installation process which would place the executables at a fixed place.
    Thanks in advance to everyone,
    Daniel Rampanelli

  • How can i execute a .jar or .jad through  java?

    I want to execute a .jar like i do in SE using the class RunTime in ME does anybody know how can i do it? There is no method exec in MIDP Runtime API

    I have a MIDlet that receives a jar file from another PDA using DatragramConection and FileConnection. It's working well. When i'm running my application i'll send the jar file to another aplication and this application should receive, execute and return the result. For example, if i have a simple program that prints Hello World. I'll send the program the other PDA will execute and then return a String. I have to call the jr file through java because my MIDlet wil be already running.
    Could you understand my problem?

  • Accesing a file in the Jar archive

    Hello, I am new to Java and I have a problem with my program.
    I am writing an application that among other things can read text files.
    Every thing works fine as long as run the .class
    If I pack the application into a .jar executable (with the text files inside)
    I can not reach the files any more.
    Probably I am doing something wrong during the packing...
    //this is the constructor
    public Antenna(File fos){
         try{
         FileReader oos = new FileReader(fos);
         BufferedReader filebuf = new BufferedReader(oos);
                         //I do something with the file
               oos.close();
                } catch (IOException e) {
                                              JOptionPane.showMessageDialog(this,
              "File: " + fos + " NOT FOUND", "Warning",               JOptionPane.ERROR_MESSAGE); }
    //I use something like this to initialize my class
    Ant1 = new Antenna(new File("Curzola.ant"));When I run my application like .jar (that contains the "Curzola.ant") I get the error unless the file Curzola.ant is external to the jar file in the same directory as the -jar file.
    Does someone know what I am getting wrong?
    I think it should be easy!!
    Thanks
    carlo

    If you want to read a text file line-by-line, BufferedReader is a good choice.
    If you have a InputStream, you can use classes from java.io to convert an
    input stream into a BufferedReader:
    InputStream -> InputStreamReader -> BufferedReader
    For example:
    void f(InputStream in) throws IOException {
        Reader r = new InputStreamReader(in, "ISO-8859-1");
        BufferedReader br = new BufferedReader(r);
        //use br
    }Some coders would use a different InputStreamReader constructor:
    Reader r = new InputStreamReader(in);But that uses the platform's default charset encoding, and since we are
    talking about a file in your jar, you shouldn't assume it's being decoded
    on the same platform it was encoded.
    Your original code, by the way, used FileReader, which is just a convenience
    subclass of InputStreamReader, and your code:
    FileReader r = new FileReader(file);was just shorthand for
    InputStream is = new FileInputStream(file);
    Reader r = new InputStreamReader(is);Finally, what objects should your constructor accept? One approach
    is to be super flexible and accept many types:
    public class Example {
        public Example(URL url) throws IOException {
            this(url.openStream());
        public Example(File file) throws IOException {
           this(new FileInputStream(file));
        public Example(InputStream in) throws IOException {
            this(new InputStreamReader(in, "ISO-8859-1"));
        public Example(Reader r) throws IOException {
            BufferedReader br = new BufferedReader(r);
            //use br
    }The other extreme is to accept one basic type. In your case, since you want to read text, is to accept a Reader:
    public class Example {
        public Example(Reader r) throws IOException {
            BufferedReader br = new BufferedReader(r);
            //use br
    }...and have the calling code do the work of constructing an appropriate reader.

  • Want help to execute the programm of MethodEntryEvent

    Hi,
    I am trying to develop a programm for automatic logging in the programme. I took the hepl of java API and the Google site for searching some programms and successed also. but while running these sample programms i am getting classNotFound exception and some other exceptions also. i executed the programm Seq.java downloaded from the site http://search.cpan.org/src/PHILCROW/UML-Sequence-0.05/java/Seq.java. i am not able to understand how to execute it. what ever i tried its giving the same output whatever defined in the System.err() in the file. but it should display the corrosponding class details for which i need to see the output.
    can anyone help me in this regard and tell me the process to execute the programm.
    i took another e.g. trace example, which (in J2SE 1.4.x or 5.x) will be found in $JAVA_HOME/demo/jpda/examples.jar and unpacking it by
    jar -xvf $JAVA_HOME/demo/jpda/examples.jar i found the
    com/sun/tools/example/trace/Trace.java
    when i tried to execute it to see the output for some other programm i got the following exceptions,
    -- VM Started --
    ====== main ======
    main -- DateExample
    | Exception: instance of java.lang.ClassNotFoundException(id=97) catch: java.lang.ClassLoader:286
    | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=98) catch: java.lang.ClassLoader:286
    | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=98) catch: java.lang.ClassLoader:286
    | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=99) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=99) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=100) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=100) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=101) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=101) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=102) catch: java.util.ResourceBundle:1074
    | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=102) catch: java.util.ResourceBundle:1074
    | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=105) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=105) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=106) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=106) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=115) catch: null
    | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=118) catch: null
    ====== main end ======
    -- The application exited --
    i execute this programm i used the command as
    java Trace -output trace.log DateExample
    where trace.log is output file and DateExample is the java file.
    Can any one help me in this regard to execute the programms and can give me a detailed solution procedure.
    can anyone suggest me any other programm for auto exit and entry display for classes or methods with detailed execution steps.
    Thanks,

    Hi,
    i tried by setting the class path in the environment variables.
    still i am getting the same exceptions. i m sending the files on which i m working and requesting to give some solution. the files are
    // Trace.java
    import com.sun.jdi.VirtualMachine;
    import com.sun.jdi.Bootstrap;
    import com.sun.jdi.connect.*;
    import java.util.Map;
    import java.util.List;
    import java.util.Iterator;
    import java.io.PrintWriter;
    import java.io.FileWriter;
    import java.io.IOException;
    * This program traces the execution of another program.
    * See "java Trace -help".
    * It is a simple example of the use of the Java Debug Interface.
    * @version @(#) Trace.java 1.4 03/01/23 17:55:38
    * @author Robert Field
    public class Trace {
    // Running remote VM
    private final VirtualMachine vm;
    // Thread transferring remote error stream to our error stream
    private Thread errThread = null;
    // Thread transferring remote output stream to our output stream
    private Thread outThread = null;
    // Mode for tracing the Trace program (default= 0 off)
    private int debugTraceMode = 0;
    // Do we want to watch assignments to fields
    private boolean watchFields = false;
    // Class patterns for which we don't want events
    private String[] excludes = {"java.*", "javax.*", "sun.*",
    "com.sun.*"};
    * main
    public static void main(String[] args) {
    //new Trace(args);
    //DateExample d = new DateExample();
    //String[] arg = {(new DateExample().toString())};
    //String[] arg = {"E:/java_progs/classLoader/project logging/com/sun/tools/example/trace/DateExample.java"};
    //d.dateDisplay();
    new Trace(args);
    * Parse the command line arguments.
    * Launch target VM.
    * Generate the trace.
    Trace(String[] args) {
    System.out.println("entered into the method Trace(String[] args)");
    PrintWriter writer = new PrintWriter(System.out);
    System.out.println("Printer object created.....");
    int inx;
    for (inx = 0; inx < args.length; ++inx) {
    System.out.println("inside for loop args.length is "+args.length+" and the data is "+args[inx]);
    String arg = args[inx];
    if (arg.charAt(0) != '-') {
    break;
    if (arg.equals("-output")) {
    System.out.println("inside args== -output");
    try {
    writer = new PrintWriter(new FileWriter(args[++inx]));
    System.out.println("writer object createed....");
    } catch (IOException exc) {
    System.err.println("Cannot open output file: " + args[inx]
    + " - " + exc);
    System.exit(1);
    } else if (arg.equals("-all")) {
    System.out.println("inside args== -all");
    excludes = new String[0];
    } else if (arg.equals("-fields")) {
    System.out.println("inside args== -fields");
    watchFields = true;
    } else if (arg.equals("-dbgtrace")) {
    System.out.println("inside args== -bdgtrace");
    debugTraceMode = Integer.parseInt(args[++inx]);
    System.out.println("inside args== -bdgtrace the debugTraceMode is "+debugTraceMode);
    } else if (arg.equals("-help")) {
    System.out.println("inside args== -help called usage();");
    usage();
    System.exit(0);
    } else {
    System.err.println("No option: " + arg);
    usage();
    System.exit(1);
    System.out.println("the index is "+inx+" the args.length is "+args.length);
    if (inx >= args.length) {
    System.err.println("<class> missing");
    usage();
    System.exit(1);
    StringBuffer sb = new StringBuffer();
    sb.append(args[inx]);
    for (++inx; inx < args.length; ++inx) {
    sb.append(' ');
    sb.append(args[inx]);
    System.out.println("the string buffer contains \n "+sb);
    vm = launchTarget(sb.toString());
    generateTrace(writer);
    System.out.println("after generateTrace(writer)");
    * Generate the trace.
    * Enable events, start thread to display events,
    * start threads to forward remote error and output streams,
    * resume the remote VM, wait for the final event, and shutdown.
    void generateTrace(PrintWriter writer) {
    System.out.println("inside generateTrace(PrintWriter writer) the debugTraceMode is "+debugTraceMode);
    vm.setDebugTraceMode(debugTraceMode);
    EventThread eventThread = new EventThread(vm, excludes, writer);
    eventThread.setEventRequests(watchFields);
    System.out.println("inside generateTrace(PrintWriter writer) the eventThread.setEventRequests(watchFields) is ");
    eventThread.start();
    redirectOutput();
    vm.resume();
    // Shutdown begins when event thread terminates
    try {
    eventThread.join();
    errThread.join(); // Make sure output is forwarded
    outThread.join(); // before we exit
    } catch (InterruptedException exc) {
    // we don't interrupt
    writer.close();
    System.out.println("the writer is closed....");
    * Launch target VM.
    * Forward target's output and error.
    VirtualMachine launchTarget(String mainArgs) {
    System.out.println("inside VirtualMachine launchTarget(String mainArgs) "+mainArgs);
    LaunchingConnector connector = findLaunchingConnector();
    System.out.println("Lunching connector found "+connector);
    Map arguments = connectorArguments(connector, mainArgs);
    try {
    return connector.launch(arguments);
    } catch (IOException exc) {
    throw new Error("Unable to launch target VM: " + exc);
    } catch (IllegalConnectorArgumentsException exc) {
    throw new Error("Internal error: " + exc);
    } catch (VMStartException exc) {
    throw new Error("Target VM failed to initialize: " +
    exc.getMessage());
    void redirectOutput() {
    Process process = vm.process();
    System.out.println("inside redirectOutput() after getting the virtual m/c process");
    // Copy target's output and error to our output and error.
    errThread = new StreamRedirectThread("error reader",
    process.getErrorStream(),
    System.err);
    outThread = new StreamRedirectThread("output reader",
    process.getInputStream(),
    System.out);
    errThread.start();
    outThread.start();
    * Find a com.sun.jdi.CommandLineLaunch connector
    LaunchingConnector findLaunchingConnector() {
    List connectors = Bootstrap.virtualMachineManager().allConnectors();
    System.out.println("inside redirectOutput() after getting the connectors list");
    Iterator iter = connectors.iterator();
    while (iter.hasNext()) {
    Connector connector = (Connector)iter.next();
    System.out.println("inside while (iter.hasNext()) after getting the connector objects from itterator");
    if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) {
    System.out.println("inside if (connector.name().equals('com.sun.jdi.CommandLineLaunch'))");
    return (LaunchingConnector)connector;
    throw new Error("No launching connector");
    * Return the launching connector's arguments.
    Map connectorArguments(LaunchingConnector connector, String mainArgs) {
    System.out.println("Map connectorArguments(LaunchingConnector connector, String mainArgs) the mainArgs is "+mainArgs);
    Map arguments = connector.defaultArguments();
    Connector.Argument mainArg =
    (Connector.Argument)arguments.get("main");
    if (mainArg == null) {
    System.out.println("inside the mainArg==null ");
    throw new Error("Bad launching connector");
    mainArg.setValue(mainArgs);
    System.out.println("the mainArg is "+mainArg);
    if (watchFields) {
    System.out.println("inside the if (watchFields)********");
    // We need a VM that supports watchpoints
    Connector.Argument optionArg =
    (Connector.Argument)arguments.get("options");
    if (optionArg == null) {
    throw new Error("Bad launching connector");
    System.out.println("inside the if (watchFields)the optionArg is "+optionArg);
    optionArg.setValue("-classic");
    System.out.println("optionArg.getValue() is ");
    return arguments;
    * Print command line usage help
    void usage() {
    System.out.println("inside usage()");
    System.err.println("Usage: java Trace <options> <class> <args>");
    System.err.println("<options> are:");
    System.err.println(
    " -output <filename> Output trace to <filename>");
    System.err.println(
    " -all Include system classes in output");
    System.err.println(
    " -help Print this help message");
    System.err.println("<class> is the program to trace");
    System.err.println("<args> are the arguments to <class>");
    // DateExample.java
    import java.util.Date;
    import java.text.DateFormat;
    import java.util.Calendar;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    public class DateExample {
    public static void main(String[] args) {
    Date a = new Date();
    System.out.println("Today is : "+a);
    Calendar ca= Calendar.getInstance();
    ca.set(a.getYear(),a.getMonth(),a.getDate());
    ca.add(Calendar.DATE,1);
    DateFormat df1 = DateFormat.getDateInstance(DateFormat.SHORT);
    String s1 = df1.format(ca.getTime());
    System.out.println("(SHORT) Today is + 1 :" + s1);
    //java.sql.Date s = new java.sql.Date(2005,6,1);
    //System.out.println("Date from sql is : "+s);
    Date a1 = new Date(2005,06,01);
    System.out.println("Today is a1 : "+a1);
    java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
    System.out.println("After format :"+formatter.format(a1));
    System.out.println("After format :"+formatter.format(new Date(s1)));
    java.text.SimpleDateFormat formatter1 = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    System.out.println("After format :"+formatter1.format(a1));
    // EventThread.java
    import com.sun.jdi.*;
    import com.sun.jdi.request.*;
    import com.sun.jdi.event.*;
    import java.util.*;
    import java.io.PrintWriter;
    * This class processes incoming JDI events and displays them
    * @version @(#) EventThread.java 1.4 03/01/23 17:55:38
    * @author Robert Field
    public class EventThread extends Thread {
    private final VirtualMachine vm; // Running VM
    private final String[] excludes; // Packages to exclude
    private final PrintWriter writer; // Where output goes
    static String nextBaseIndent = ""; // Starting indent for next thread
    private boolean connected = true; // Connected to VM
    private boolean vmDied = true; // VMDeath occurred
    // Maps ThreadReference to ThreadTrace instances
    private Map traceMap = new HashMap();
    EventThread(VirtualMachine vm, String[] excludes, PrintWriter writer) {
    super("event-handler");
    this.vm = vm;
    this.excludes = excludes;
    this.writer = writer;
    System.out.println("inside EventThread(VirtualMachine vm, String[] excludes, PrintWriter writer) ");
    * Run the event handling thread.
    * As long as we are connected, get event sets off
    * the queue and dispatch the events within them.
    public void run() {
    System.out.println("inside run() ");
    EventQueue queue = vm.eventQueue();
    while (connected) {
    System.out.println("inside while (connected) ");
    try {
    EventSet eventSet = queue.remove();
    EventIterator it = eventSet.eventIterator();
    System.out.println("got EventSet and EventIterator *** ");
    while (it.hasNext()) {
    System.out.println("inside while (it.hasNext())");
    handleEvent(it.nextEvent());
    eventSet.resume();
    System.out.println("event is resumed ***** ");
    } catch (InterruptedException exc) {
    // Ignore
    } catch (VMDisconnectedException discExc) {
    handleDisconnectedException();
    break;
    * Create the desired event requests, and enable
    * them so that we will get events.
    * @param excludes Class patterns for which we don't want events
    * @param watchFields Do we want to watch assignments to fields
    void setEventRequests(boolean watchFields) {
    System.out.println("inside setEventRequests(boolean watchFields) ");
    EventRequestManager mgr = vm.eventRequestManager();
    // want all exceptions
    ExceptionRequest excReq = mgr.createExceptionRequest(null,
    true, true);
    // suspend so we can step
    excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    excReq.enable();
    MethodEntryRequest menr = mgr.createMethodEntryRequest();
    for (int i=0; i<excludes.length; ++i) {
    System.out.println("inside for (int i=0; i><excludes.length; ++i) for createMethodEntryRequest() ");
    menr.addClassExclusionFilter(excludes);
    menr.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    menr.enable();
    MethodExitRequest mexr = mgr.createMethodExitRequest();
    for (int i=0; i><excludes.length; ++i) {
    System.out.println("inside for (int i=0; i><excludes.length; ++i) for createMethodExitRequest() ");
    mexr.addClassExclusionFilter(excludes);
    mexr.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    mexr.enable();
    ThreadDeathRequest tdr = mgr.createThreadDeathRequest();
    // Make sure we sync on thread death
    tdr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    tdr.enable();
    if (watchFields) {
    System.out.println("inside if (watchFields) ************** ");
    ClassPrepareRequest cpr = mgr.createClassPrepareRequest();
    for (int i=0; i><excludes.length; ++i) {
    System.out.println("inside for (int i=0; i><excludes.length; ++i) the excludes.length is ************** "+excludes.length);
    cpr.addClassExclusionFilter(excludes);
    cpr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    cpr.enable();
    * This class keeps context on events in one thread.
    * In this implementation, context is the indentation prefix.
    class ThreadTrace {
    final ThreadReference thread;
    final String baseIndent;
    static final String threadDelta = " ";
    StringBuffer indent;
    ThreadTrace(ThreadReference thread) {
    System.out.println("inside ThreadTrace(ThreadReference thread)");
    this.thread = thread;
    this.baseIndent = nextBaseIndent;
    indent = new StringBuffer(baseIndent);
    nextBaseIndent += threadDelta;
    println("====== " + thread.name() + " ======");
    private void println(String str) {
    System.out.println("inside void println(String str)");
    writer.print(indent);
    writer.println(str);
    void methodEntryEvent(MethodEntryEvent event) {
    System.out.println("inside methodEntryEvent(MethodEntryEvent event)");
    println(event.method().name() + " -- "
    + event.method().declaringType().name());
    indent.append("| ");
    void methodExitEvent(MethodExitEvent event) {
    System.out.println("inside methodExitEvent(MethodExitEvent event)");
    indent.setLength(indent.length()-2);
    void fieldWatchEvent(ModificationWatchpointEvent event) {
    System.out.println("inside fieldWatchEvent(ModificationWatchpointEvent event)");
    Field field = event.field();
    Value value = event.valueToBe();
    println(" " + field.name() + " = " + value);
    void exceptionEvent(ExceptionEvent event) {
    System.out.println("inside exceptionEvent(ExceptionEvent event) ");
    println("Exception: " + event.exception() +
    " catch: " + event.catchLocation());
    // Step to the catch
    EventRequestManager mgr = vm.eventRequestManager();
    StepRequest req = mgr.createStepRequest(thread,
    StepRequest.STEP_MIN,
    StepRequest.STEP_INTO);
    System.out.println("stepRequest is created "+req);
    req.addCountFilter(1); // next step only
    req.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    req.enable();
    // Step to exception catch
    void stepEvent(StepEvent event) {
    System.out.println("inside stepEvent(StepEvent event) ");
    // Adjust call depth
    int cnt = 0;
    indent = new StringBuffer(baseIndent);
    try {
    cnt = thread.frameCount();
    System.out.println("inside try cnt is "+cnt);
    } catch (IncompatibleThreadStateException exc) {
    while (cnt-- > 0) {
    System.out.println("inside while indent is "+indent);
    indent.append("| ");
    EventRequestManager mgr = vm.eventRequestManager();
    mgr.deleteEventRequest(event.request());
    void threadDeathEvent(ThreadDeathEvent event) {
    System.out.println("inside threadDeathEvent(ThreadDeathEvent event) ");
    indent = new StringBuffer(baseIndent);
    println("====== " + thread.name() + " end ======");
    * Returns the ThreadTrace instance for the specified thread,
    * creating one if needed.
    ThreadTrace threadTrace(ThreadReference thread) {
    ThreadTrace trace = (ThreadTrace)traceMap.get(thread);
    System.out.println("inside ThreadTrace threadTrace(ThreadReference thread) trace is "+trace);
    if (trace == null) {
    trace = new ThreadTrace(thread);
    traceMap.put(thread, trace);
    return trace;
    * Dispatch incoming events
    private void handleEvent(Event event) {
    System.out.println("inside handleEvent(Event event) ");
    if (event instanceof ExceptionEvent) {
    System.out.println("inside handleEvent(Event event) in ExceptionEvent ");
    exceptionEvent((ExceptionEvent)event);
    } else if (event instanceof ModificationWatchpointEvent) {
    System.out.println("inside handleEvent(Event event) in ModificationWatchpointEvent ");
    fieldWatchEvent((ModificationWatchpointEvent)event);
    } else if (event instanceof MethodEntryEvent) {
    System.out.println("inside handleEvent(Event event) in MethodEntryEvent ");
    methodEntryEvent((MethodEntryEvent)event);
    } else if (event instanceof MethodExitEvent) {
    System.out.println("inside handleEvent(Event event) in MethodExitEvent ");
    methodExitEvent((MethodExitEvent)event);
    } else if (event instanceof StepEvent) {
    System.out.println("inside handleEvent(Event event) in StepEvent ");
    stepEvent((StepEvent)event);
    } else if (event instanceof ThreadDeathEvent) {
    System.out.println("inside handleEvent(Event event) in ThreadDeathEvent ");
    threadDeathEvent((ThreadDeathEvent)event);
    } else if (event instanceof ClassPrepareEvent) {
    System.out.println("inside handleEvent(Event event) in ClassPrepareEvent ");
    classPrepareEvent((ClassPrepareEvent)event);
    } else if (event instanceof VMStartEvent) {
    System.out.println("inside handleEvent(Event event) in VMStartEvent ");
    vmStartEvent((VMStartEvent)event);
    } else if (event instanceof VMDeathEvent) {
    System.out.println("inside handleEvent(Event event) in VMDeathEvent ");
    vmDeathEvent((VMDeathEvent)event);
    } else if (event instanceof VMDisconnectEvent) {
    System.out.println("inside handleEvent(Event event) in VMDisconnectEvent ");
    vmDisconnectEvent((VMDisconnectEvent)event);
    } else {
    System.out.println("inside handleEvent(Event event) in else unexcepted type ");
    throw new Error("Unexpected event type");
    * A VMDisconnectedException has happened while dealing with
    * another event. We need to flush the event queue, dealing only
    * with exit events (VMDeath, VMDisconnect) so that we terminate
    * correctly.
    synchronized void handleDisconnectedException() {
    System.out.println("inside handleDisconnectedException() ");
    EventQueue queue = vm.eventQueue();
    while (connected) {
    System.out.println("inside handleDisconnectedException() in while (connected) ");
    try {
    EventSet eventSet = queue.remove();
    EventIterator iter = eventSet.eventIterator();
    System.out.println("inside handleDisconnectedException() got EventSet & EventIterator ");
    while (iter.hasNext()) {
    System.out.println("inside handleDisconnectedException() in while (iter.hasNext()) ");
    Event event = iter.nextEvent();
    if (event instanceof VMDeathEvent) {
    System.out.println("inside handleDisconnectedException() in if ");
    vmDeathEvent((VMDeathEvent)event);
    } else if (event instanceof VMDisconnectEvent) {
    System.out.println("inside handleDisconnectedException() in else ");
    vmDisconnectEvent((VMDisconnectEvent)event);
    eventSet.resume(); // Resume the VM
    } catch (InterruptedException exc) {
    // ignore
    private void vmStartEvent(VMStartEvent event) {
    System.out.println("inside vmStartEvent(VMStartEvent event)**** ");
    writer.println("-- VM Started --");
    // Forward event for thread specific processing
    private void methodEntryEvent(MethodEntryEvent event) {
    System.out.println("inside methodEntryEvent(MethodEntryEvent event)****** ");
    threadTrace(event.thread()).methodEntryEvent(event);
    // Forward event for thread specific processing
    private void methodExitEvent(MethodExitEvent event) {
    System.out.println("inside methodExitEvent(MethodExitEvent event)****** ");
    threadTrace(event.thread()).methodExitEvent(event);
    // Forward event for thread specific processing
    private void stepEvent(StepEvent event) {
    System.out.println("inside stepEvent(StepEvent event)****** ");
    threadTrace(event.thread()).stepEvent(event);
    // Forward event for thread specific processing
    private void fieldWatchEvent(ModificationWatchpointEvent event) {
    System.out.println("inside fieldWatchEvent(ModificationWatchpointEvent event)***** ");
    threadTrace(event.thread()).fieldWatchEvent(event);
    void threadDeathEvent(ThreadDeathEvent event) {
    System.out.println("inside threadDeathEvent(ThreadDeathEvent event)****** ");
    ThreadTrace trace = (ThreadTrace)traceMap.get(event.thread());
    if (trace != null) { // only want threads we care about
    trace.threadDeathEvent(event); // Forward event
    * A new class has been loaded.
    * Set watchpoints on each of its fields
    private void classPrepareEvent(ClassPrepareEvent event) {
    System.out.println("inside classPrepareEvent(ClassPrepareEvent event)****** ");
    EventRequestManager mgr = vm.eventRequestManager();
    List fields = event.referenceType().visibleFields();
    for (Iterator it = fields.iterator(); it.hasNext(); ) {
    System.out.println("inside classPrepareEvent(ClassPrepareEvent event) inside for loop Iterator ****** ");
    Field field = (Field)it.next();
    ModificationWatchpointRequest req =
    mgr.createModificationWatchpointRequest(field);
    for (int i=0; i<excludes.length; ++i) {
    System.out.println("inside classPrepareEvent(ClassPrepareEvent event) inside for loop int ****** ");
    req.addClassExclusionFilter(excludes);
    req.setSuspendPolicy(EventRequest.SUSPEND_NONE);
    req.enable();
    private void exceptionEvent(ExceptionEvent event) {
    System.out.println("inside exceptionEvent(ExceptionEvent event)****** ");
    ThreadTrace trace = (ThreadTrace)traceMap.get(event.thread());
    if (trace != null) { // only want threads we care about
    trace.exceptionEvent(event); // Forward event
    public void vmDeathEvent(VMDeathEvent event) {
    System.out.println("inside vmDeathEvent(VMDeathEvent event)****** ");
    vmDied = true;
    writer.println("-- The application exited --");
    public void vmDisconnectEvent(VMDisconnectEvent event) {
    System.out.println("inside vmDisconnectEvent(VMDisconnectEvent event)****** ");
    connected = false;
    if (!vmDied) {
    System.out.println("inside vmDisconnectEvent(VMDisconnectEvent event)in if loop ****** ");
    writer.println("-- The application has been disconnected --");
    // StreamRedirectThread.java
    import java.io.*;
    * StreamRedirectThread is a thread which copies it's input to
    * it's output and terminates when it completes.
    * @version @(#) StreamRedirectThread.java 1.4 03/01/23 17:55:38
    * @author Robert Field
    class StreamRedirectThread extends Thread {
    private final Reader in;
    private final Writer out;
    private static final int BUFFER_SIZE = 2048;
    * Set up for copy.
    * @param name Name of the thread
    * @param in Stream to copy from
    * @param out Stream to copy to
    StreamRedirectThread(String name, InputStream in, OutputStream out) {
    super(name);
    this.in = new InputStreamReader(in);
    this.out = new OutputStreamWriter(out);
    setPriority(Thread.MAX_PRIORITY-1);
    System.out.println("inside StreamRedirectThread(String name, InputStream in, OutputStream out) ****** ");
    * Copy.
    public void run() {
    System.out.println("inside StreamRedirectThread class in run() ****** ");
    try {
    char[] cbuf = new char[BUFFER_SIZE];
    int count;
    while ((count = in.read(cbuf, 0, BUFFER_SIZE)) >= 0) {
    System.out.println("inside run() in while loop the count is ****** "+count);
    out.write(cbuf, 0, count);
    out.flush();
    } catch(IOException exc) {
    System.err.println("Child I/O Transfer - " + exc);
    by using these files i m trying to trace the execution of DateExample.java through the Trace.java by using the command
    java Trace -output trace.log DateExample
    by executiing i m getting the exceptions in the output file trace.log
    -- VM Started --
    ====== main ======
    main -- DateExample
    | Exception: instance of java.lang.ClassNotFoundException(id=97) catch: java.lang.ClassLoader:286
    | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=99) catch: java.lang.ClassLoader:286
    | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=99) catch: java.lang.ClassLoader:286
    | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=100) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=100) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=101) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=101) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=102) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=102) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.util.zip.ZipException(id=104) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.util.zip.ZipException(id=104) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=105) catch: java.util.ResourceBundle:1074
    | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.lang.ClassNotFoundException(id=105) catch: java.util.ResourceBundle:1074
    | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=108) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=108) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=109) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=109) catch: sun.misc.URLClassPath:293
    | | | | | | | | | | | | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=118) catch: null
    | | | | | | | | | | | | | | Exception: instance of java.io.FileNotFoundException(id=121) catch: null
    ====== main end ======
    -- The application exited --
    Could any one help me in this regard to execute the programm.
    Could any one help to show the execution of the Seq.java downloaded from the site http://search.cpan.org/src/PHILCROW/UML-Sequence-0.05/java/Seq.java, what i mentioned in my previous mail.
    thanks,

Maybe you are looking for

  • No (suitable) purchase order/item found for MR11

    Hi, I am trying to do an MR11 on a PO but it says that there is no PO found. But when I look at the PO history there is an entry in Total variances through IR. Then why does it say there is nothing to do MR11 for? The PO quantity is 440.030 The GR Qu

  • How to fixed a cracked screen

    What can I do to get my screen fixed without a warrenty

  • ABAP field symbols and PERL reference variables to unnamed arrays.

    Rob - Please do NOT delete this post even though it contains this link: ABAP field symbols and PERL reference variables to unnamed arrays. to a question I posted in the Scripting Languages forum. It's a question that should be of interest to ABAP pro

  • No authority certificate to continue

    For loading new  applications phone gives the message " NO AUTHORITY CERTIFUCATE ON PHONE  ''   and application set up or working stops. 

  • Unix script for checking the user account status

    Hi All, i have created one unix script to check the status of the user in diff databases. #!/bin/ksh useracctreport.txt if [ ! -f hh ]; then echo "Database file does not exist" fi echo "Enter Username" read USER echo "Enter the password" stty -echo r