Swing from VB

Hi!
Can anyone help me on this one?
I have a Swing program that opens a JFrame, takes in some input in a JTextField and uses that to do a series of Keyboard entries(using java.awt.Robot).This part works fine.
But now, I have to integrate this code with a VB program.There will be a button on a VB form, from where this program has to execute.
Accordingly, I changed my code as follows:
1)I removed my main method and added an ordinary method instead.
2)Downloaded and installed MS JVM and MS SDK for Java and used the javareg tool to register my main Java class(the entry point, I have a few more java classes totally) and created a .tlb file.
3)Using VB environment, I refer to the tlb and the Java class and its methods are visible on the "intellihelp"
4)From VB I call the method as entry point to the Java code.
Problem:
The following error occurs when the part to call the Java class from VB executes:
Run time error:2147467259(80004005)
Automation Error
Unspecified Error
Any idea what I need to do?
Thanks in advance.
mat430.

Swing doesn't work in the MS jdk. Sorry, you have to use the Sun or IBM jdk. It might work if you use an old verison of swing. Not sure if you can still get one though.
You can always execute the java command (assuming that they have a jre installed).

Similar Messages

  • Urgent ! how to run swing from dos

    hi
    how should i run swing program through dos prompt.when found in i tried compiling from c:\jdk\bin i got an error "package javax.swing not import".
    viji

    what you willdo is this,
    at the top of your code type the line.
    import javax.swing.*;
    //for event type the next line..
    import javax.swing.event.*;
    import java.awt.event.*;
    I think this should solve your problem.

  • Problem Loading an Image with javax Swing from a JApplet

    First of all, i use JCreator as java creater and have the newest version of java sdk version.
    Now i need to load an image from the harddrive on which the JApplet is located. I need to do this from inside the JApplet. I have put my pictures in a map 'images' which is located in the same directory as the classes + htm file. It works from inside JCreator, but as soon as i open the normal htm it just WON'T load that image (grmbl).
    Here is my code for loading the image:
    public BufferedImage loadImage (String filename, int transparency)
         Image image;
         if (app)
              image = Toolkit.getDefaultToolkit().getImage(("./images/"+filename));
         else
              String location = "";
              location = "./images/"+filename;
              image = Toolkit.getDefaultToolkit().getImage(location);
         MediaTracker mediaTracker = new MediaTracker(new Container());
         mediaTracker.addImage(image, 0);
         try
              mediaTracker.waitForID(0);
         catch (Exception e)
    Could anybody help me out here??
    I tried a url already using getCodeBase() or getDocumentBase() but that gives an error because it cannot find those if using a JApplet.

    Why don't you use javax.swing.ImageIcon? If you already have a flag telling if it's an application or applet, use the getDocumentBase() to base the URL in the applet part only.

  • Send arraylist to swings from servlet

    Hi,
    I send string to jsp from swings using URL(pass as a query string)
    And then call servet from jsp(submit some values to this servlet from jsp)
    Now i want to send ArrayList to my swings ,
    How it is,
    i know call servlet from swings,retrive values from servlet to swings. This is two way communication,
    But now my requirement is one way, i didn't call servlet directly from swings, i call from jsp
    Help me,
    Thanks in advance

    Thanks for reply
    i write code in my swing as
    ArrayList pdetails;
    URL url=new URL(getCodeBase()+"sample.jsp");
                URLConnection con =url.openConnection();
                con.setDoInput(true);
                con.setDoOutput(true);
                con.setUseCaches(false);
                OutputStream outstream = con.getOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(outstream);
                oos.writeObject(pdetails);
                oos.flush();
                oos.close();
                AppletContext context=getAppletContext();
                context.showDocument(url,"_blank");my jsp code is
    <%@page import="java.io.*,java.util.*"%>
    <%
    ObjectInputStream inputFromApplet = null;
    ArrayList transmitContent =null;
    inputFromApplet = new ObjectInputStream(request.getInputStream());
    System.out.println(inputFromApplet);
    transmitContent = (ArrayList) inputFromApplet.readObject();
    out.println(transmitContent);
    %>
    but i got an exception like this21:28:50,078 WARN [[jsp]] Servlet.service() for servlet jsp threw exception
    java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream
    .java:2232)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputS
    tream.java:2698)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:750
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:268)
    at org.apache.jsp.sample_jsp._jspService(org.apache.jsp.sample_jsp:52)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
    .java:322)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
    14)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
    lter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:178)
    at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
    ipalValve.java:54)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
    yAssociationValve.java:174)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
    e.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
    a:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :868)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
    rocessConnection(Http11BaseProtocol.java:663)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
    int.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
    kerThread.java:112)
    at java.lang.Thread.run(Thread.java:595)

  • Calling java swing from c

    Hi
    Is there any difference between calling a java swing application from c and calling a java class that uses no user interface components?
    Do you have to add any extra paths to the classpath variable in the virtual machine structure to make swing work when calling from c?
    To learn how to call java from c I wrote a simple hello world java program and got this working. As soon as I added a JFrame swing component and tried to run the c program then it crashes.
    Thanks for you help.

    Is there any difference between calling a java swing application from c and calling a java class that uses no user interface components?
    No.
    As soon as I added a JFrame swing component and tried to run the c program then it crashes.
    Sounds like you've got a bug in your JNI. Are you making sure to check all the return codes from the JNI functions?
    God bless,
    -Toby Reyelts

  • Apple TV locks when 'Add folder to library' on iTunes being streamed from

    This problem seems consistently repeatable on my set-up. Was just wondering whether anyone else has experienced this problem.
    Apple TV is playing music streamed, screen saver may or may not be active. I then copy new music folders into my iTunes music directory and then select 'Add folder to library' on iTunes and select my music directory. iTunes updates correctly and I can then edit/play/add artwork to the newly added music.
    However, back on the Apple TV, the music continues to play but the playback position no longer updates although the animated swinging from side to side every so often still works or if the screen saver is active it continues as normal. The Apple TV no longer responds to the remote control. I have left then music playing before and it continues until it has no more music to play, e.g. got to end of album.
    I have found only one way out, which does not always work (I sometimes have to remove power from the Apple TV to reset it). If I close down iTunes, after a number of seconds (5 to 15 usually) the Apple TV pops up a button asking to reconnect to sources. I can then restart iTunes and the Apple TV reconnects and I can select what I want to do.

    You'll probably have better luck asking the question here -> Windows EightForums
    iTunes isn't designed to work with Windows 8 or any beta software, so theres no suprise that it isn't working as expected.

  • Lightroom and Photoshop Implications for switching platforms from a PC to Mac

    I'm looking at purchasing a new computer and making the swing from PC to Mac. Currently, I'm running Photoshop CS5 and Lightroom 4 on my PC. If I switch to a Mac, what are the implications? Can my Lightroom catalogs on my PC be easily transferred?  Will I be forced to upgrade to creative cloud?

    You can still purchase Photoshop CS6, I think.
    Yes, definitely.
    Whether it's worth upgrading to 2.5 year old superseded software is up to the purchaser.
    Link: Creative Suite 6
    The $10/month Cloud Photography Plan (PS CC 2014 + LR5 + LR mobile) may be worth considering

  • Memory Optmization in Swing

    Am currently working in a project in which Server intiates the Clients application[Swing] and keeps track of the application.For a single client it consumes some 20MB memory.For more than 200 client it consumes 20Mb*200 & More memory .Is there any way by which i can optimize the memory consumption in Java?.
    Note : I tried calling the swing from a JSP.But even that failed.
    Any body has the answer ?

    20mb per client is indeed a lot. This can only mean your application stores a lot of objects which take that much memory. It could be that you are generating "memory leaks", as in objects which you create but are always referenced so the garbage collector doesn't free them.

  • Best Book for Swing Programming

    Can anyone tell me the name of a swing related book which covers all the major topic of swing programming.
    Thanks in advance

    I like Java Swing from OReilly. Big thick book, and contains nothing but Swing.

  • Reading each keystroke from a console app?

    I'm using Sun JDK 1.3.0_02 on RedHat Linux 7.1.
    I've written a console application (no GUI, no Swing), from which I need to read each keystroke from the keyboard as it is typed.
    My loop basically waits (blocks) on System.in.read(), and disposes of each byte as it is read.
    Unfortunately, the way the app executes, my Java app doesn't seem to be given any keyboard input until the user presses ENTER. In addition, each keystroke is echoed to the console display, which I don't want.
    Can anyone point me in the right direction to solve this? I can't use any GUI components as this needs to be a console app.
    Thank you,
    Bryan

    This can be fixed with a tiny JNI program. As long as the 'c' call getch() works the same on all platforms:
    // The Java class
    import java.io.*;
    public class ConsoleInputStream extends InputStream
        public native int read();
        static
            System.loadLibrary("ConsoleInputStream");
    // The JNI header
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class ConsoleInputStream */
    #ifndef _Included_ConsoleInputStream
    #define _Included_ConsoleInputStream
    #ifdef __cplusplus
    extern "C" {
    #endif
    #undef ConsoleInputStream_SKIP_BUFFER_SIZE
    #define ConsoleInputStream_SKIP_BUFFER_SIZE 2048L
    /* Inaccessible static: skipBuffer */
    * Class:     ConsoleInputStream
    * Method:    read
    * Signature: ()I
    JNIEXPORT jint JNICALL Java_ConsoleInputStream_read
      (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    // The JNI 'C' code
    #include "..\classes\generated source\consoleInputStream.h"
    #include "conio.h"
    JNIEXPORT jint JNICALL Java_ConsoleInputStream_read(JNIEnv * env, jobject obj)
        return getch();
    // The test program
    public class Console
        public static void main(String[] args)
            try
                System.setIn(new ConsoleInputStream());
                while(true)
                    int ch=System.in.read();
                    if(ch=='\r')
                        break;
                    else
                        System.out.print((char)ch);
            catch(Exception ex)
                ex.printStackTrace();
    // the build script (Windows)
    cl -I\j2sdk1.4.0\include -I\j2sdk1.4.0\include\win32 ConsoleInputStream.cpp /MD /LD user32.lib /link/out:..\classes\ConsoleInputStream.dllHope this helps :)

  • How start JRE with swing/awt disabled?

    Hello,
    I find this exception in tomcat log:
    Exception in thread "TimerQueue" java.lang.UnsatisfiedLinkError: /usr/java/jre1.6.0_21/lib/amd64/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at sun.security.action.LoadLibraryAction.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.NativeLibLoader.loadLibraries(Unknown Source)
    at sun.awt.DebugHelper.<clinit>(Unknown Source)
    at java.awt.EventQueue.<clinit>(Unknown Source)
    at javax.swing.SwingUtilities.invokeLater(Unknown Source)
    at javax.swing.Timer.post(Unknown Source)
    at javax.swing.TimerQueue.postExpiredTimers(Unknown Source)
    at javax.swing.TimerQueue.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    This occurs on a Linux server on which I removed all X11 packages.
    I wonder if there is a way I could disable awt/swing from JRE since no GUI is used ?
    thanks for inputs.

    thanks for suggestion. I did add the option in tomcat startup command-line, and will check the log for such exception in coming days,
    thanks much.

  • Future of Swing and other GUI technologies

    Does anyone have any opinion of what the future of Swing is going to look like?
    My opinion is that Swing (like Java) seriously kicks butt. Right now there are very few Swing applications around that I can gather. But as computer chips are doubling in speed about every two years I don't think anything can stop Java Swing from dominating in 5 to 10 years time.
    Swing de-geekafies the software developement process. Its not about programming anymore, it's about OO Design.
    PS - does anyone else use the most awesome Java IDE in existence? ie. IntelliJ IDEA?

    I've been using Swing/JFC since it's early inceptions in 1997. Heck, I recall that we were initially on the 0.4 release and the pace at which the folks in the Swing team were churning out new 0.x versions was quite phenomenal.
    That said, it has evolved into a great class library with plenty of functionality - way beyond what most people require.
    As for dominance - who knows, but I'm sure it will be extremely popular at least for the next few years, perhaps longer.
    My $0.02 worth.
    cheers,
    Greg
    P.S: Yes, I'm using Intelli/J Idea and I think it's a fantastic IDE. Much, much better than anything I've used in the past (which includes JBuilder, J++, etc). :-)

  • How do I keep more than one safari page open at the same time?

    New to Mac.  I'm used to being able to have several applications open at the same time, and able to check emails, eBay, camera for downloading photos, etc., but when trying this on Mac, I can't seem to figure out how to swing from email to something else....oh, it opens up eBay and other pages, but not where I left it...I have to keep starting from the beginning...name, password, etc.   I can't have 3, 4 or 5 safari pages open at the same time??  This is making my life cumbersome, and running back to the basement office and using my dying Dell desktop where life was a bit simpler.  Sometimes I need to copy a few paragraphs on one website into another....and its taking me way too long to get this done.  I know there's a way of doing this on Mac....

    Hi Suzkas,
    I was new to mac a short time ago and I had frustrations in the learning curve especially as I was so used to working with PC.
    If you look at the top left of the screen you will see the words SAFARI next to the apple logo. if not then either open safari or click on the window and the mac will then show safari at the top. If you now click on FILE you can select NEW WINDOW or NEW TAB as you wish. I often use new tab and switch between them. If you go to VIEW and select CUSTOMISE TOOLBAR you can drag an icon to the top of the safari window and you won't have to keep going to the menu to add a new tab. I will sometimes select new window to keep something separate from my other work.
    If you close down a window you will often lose your place, but using the tab system you will leave the window active unless you select the cross to terminate. If you have a separate window open you can select the orange blob (between the red and green at the top) and the window will slide down to the dock and stay there, active, for you to return and continue.
    Hope this help, stay with it, go see the instore staff and pretty soon you wont look back
    PS I have PARALLELLS6 running with a copy of windows 7 on my mac. This means that I can switch to microsoft if I want to. However, with office for mac installed I rarely need to now, the only time I ever open windows is for an application that has no mac version.

  • Running multiple java apps simultaneously, each using a different jre.

    I have a situation where I have 3 or 4 applications (and one applet) that were built over time, each with a different version of the jdk (ranging from 1.2.2.005 to 1.3.2). I need to know of a way (and it must exist) to run each of these applications on the same machine, and at runtime, have each application (or applet) run with its respective version of the jre. Certainly, one could change some source code and make all programs compatible with a particular jre, but that doesn't solve my problem if a new app is built with a new version of the jdk down the road. Currently, each runs fine by themselves, but if I try to run them together as different processes, some won't do anything because the default jre may not be what it needs. Would the Java Plug-in software have a role to play in this? Is there a way to specify (link) which application should use which jre?
    P.S. These applications (right now) don't have to interact or interface in any way. I just need to have them all running as separate processes on the same machine and be able to jump from one to the other.

    However ... if you have the programs running in Java1.x, I
    wouldn't recommend to let it run under Java 1.y; atleast
    not without thorough testing.I do it all the time and have not had a problem. I'm
    currently using JDK 1.4 beta 3 and I regularly run a
    Java application written with JDK 1.1.
    It sounds like the programs you are running are
    relying on behavior that is not guaranteed. If that
    behavior changes in a later version, it can break your
    program. Program to the contracts provided by other
    classes and packages, and you should have few or no
    problems.I guess you are right. Maybe you can help me with the following problem (this is off this topic, I know): I have Swing JDK 1.2 and Swing from JDK 1.3. I have to register keys on components.
    In JDK 1.2 I can use registerKeyBoardAction, in JDK 1.3 I have to use input maps and action maps. Both solutions only work with certain JDK. What I did was writing code which detects the java version and takes the appropriate action to register the keys. To make the thing compile in 1.2, I have to use reflection for the input/action map methods, because they are only available in 1.3.
    Any idea how to solve this more elegantly ?

  • Java.awt availability in CDC Toolkit ?

    Hi guys and girls,
    I've just tried out the Sun Java Toolkit for CDC 1.0 .. I tried making a simple app which uses awt components, such as Frame, Label, Button .. but the Label and Button just wont compile. I always thought that CDC has all the lib for the j2se's java.awt.
    Quoted from CDC FAQ :
    CDC currently supports three profiles. Foundation Profile provides basic application support APIs without any additional support for GUIs. Personal Basis Profile includes all of the APIs contained in Foundation Profile and adds support for lightweight AWT GUI components and the xlet application model. Personal Profile includes all of the APIs contained in Personal Basis Profile and adds support for full AWT compatibility and the applet application model.
    Do i miss something .. ? Please help pointing out for me ..
    I understand that there's swing from the AGui. So i tried making a new project with a simple class containing a simple JFrame, containing a JPanel which contains a button, which can be clicked to trigger a message type JOptionPane. But when the JOptionPane appears, it fills up the entire screen, i dont quite understand what is wrong.
    Here's the code :
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class HelloWorld {
          * @param args
         public static void main(String[] args) {
              final JFrame frame = new JFrame("Ahiak");
              final JPanel panel = new JPanel(new FlowLayout());
              JButton but = new JButton("Click Me !");
              panel.add(but);
              frame.getContentPane().add(panel);
              but.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        JOptionPane.showMessageDialog(panel, "hahah !");
              frame.setVisible(true);
    }Please show some compassion and click the reply button, lol -_-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I don't know about swing, but you can try using AWT and compile it with J2SE (set compliance to 1.4). The jar file should work on your mobile device with Personal Profile.

Maybe you are looking for