How do I made "Shareware" in Java?

Say I'd love to offer up a jar file that contains a component as shareware and give it a certain amount of time to be used (eg 30 days). How can I do this?
Also, how could a person go about limiting the number of processors that a component is run on? Is that feasable?
Thanks a lot!
Eddie

It doesn't directly address the issue of time-limits,
but it does emphasize that it's more or less
impossible to hide your source code in Java... so if
someone didn't like your time limit, they could simply
extract the byte-code and use an obfuscator to create
the source code. Make it a Java Web Start application.
Sign it to prevent messing with the jars.
Enforce contacts to the server everytime the app is started up from the JWS cache by not providing the offline-allowed tag in the JNLP description.
Better implement some live data exchange (e.g. by a challenge transmitted via a socket) to make sure
the client has to contact the server at start up.
Keep track at the server side how many clients
are active.
This will provide most of what you ask, however
it will require a internet connection.
If this is not possible, you would have to emulate a Java Web Start system yourself, but that relies on different 'heartbeat' transmissions, like email sent or disks exchanged or whatever means of contact between you and the deployed client app is possible.
Make use of signed jar to keep integrity.
Make use of byte code obfuscators to prevent
reengineering that might disable security checking,
if you have to fear more than average efforts to
break your scheme.
After all there is no complete security, you can only make it more or less effort needing.
You must decide what level is ok for you.
Regards,
Marc

Similar Messages

  • How to convert oracle timestamp to java timestamp

    Hi,
    I need to convert oracle timestamp that i got from oracle database to java timestamp.I tried to use getTimestamp() to get timestamp value from oracle, but am getting NumberFormatException.
    Could any of suggest how to convert oracle timestamp to java timestamp.

    Thanks jverd ,
    then my code will be like:
    String oracleTS="11-MAR-05 11.19.20.625 AM";
    // am looking for yyyy-MM-dd HH:mm:ss format
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd
    HH:mm:ss");           
    Timestamp javaTimestamp=Timestamp.valueOf(oracleTS);
    System.out.println("javaTimestamp----->>
    "+javaTimestamp);
    ving java.lang.NumberFormatException: For input
    string: "MAR"Well, the SimpleDateFormat has to actually match the format you're trying to parse, for one thing. Then you have to actually USE the SDF, which you didn't.
    You really haven't made it clear what you're trying to do, and it doesn't appear that you bothered to study the links I provided.
    DateFormat df = new SimpleDateFormat("dd-MMM-yy HH.mm.ss.SSS aa");
    Date date = df.parse(oracleTS);
    Timestamp ts = new Timestamp(date.getTime());

  • How to make "Levels" in simple java game

    I just wanted to know if anybody knew how to make "Levels" in a java game. In my case, it is to change two polygons that are used in the background. I think you have to use an array of some kind, but i dont really know.
    Here is my source, the polygons are by the massive ///////// areas.
    I cut out the majority of the program, because it was too long.
    public class collision extends Applet implements MouseListener,MouseMotionListener
        private  Image rickImage,mazeImage;
       Image Buffer;
       Graphics gBuffer;
       int x, y;
       int[] LeftWallX = {0,204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,0};
       int[] LeftWallY = {500,499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1};
       //int[] PlayAreaX = {204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
      // int[] PlayAreaY = {499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       int[] RightWallX = {500,500,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
       int[] RightWallY = {500,0,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       boolean mouseInside, collide;
       boolean rolled = false;
       boolean msg = true;
       int sX=204,sY=490,sW=12,sH=9;
       //Declare the rectangles
       Rectangle  movingRect,finshBloc,startBloc,oopsBloc;
       //Declare the polygons
       Polygon leftWall,playerArea,rightWall;
            ///Initiate
            public void init()
                 rickImage = getImage(getDocumentBase(), "rick.jpg");
                 mazeImage = getImage(getDocumentBase(), "maze1.jpg");
                 collide=false;
                 Buffer=createImage(getSize().width,getSize().height);
                 gBuffer=Buffer.getGraphics();
                 rightWall=new Polygon(RightWallX,RightWallY,18);
                 playerArea= new Polygon(PlayAreaX,PlayAreaY,31);
                 leftWall= new Polygon(LeftWallX,LeftWallY,17);
            public void paint(Graphics g)
                 drawStuff();
                 g.drawImage (Buffer,0,0, this);
    */

    I'm not exactly sure in your case what you are trying to accomplish. If all you want to do is make new polygons for your levels then you will simply need a Vector of type level (or polygon). Store multiple levels/polygons in that vector. This can be done many ways, probably the most efficient way would be to create a class Level of sorts and create each level object from there. This way you have all your levels stored into that vector.
    I have made programs where the levels/mazes are randomly generated based on certain parameters (this way you would not need to define any specific level). This can be done inside the Level class and added to the vector so that when a level is randomly generated there are literally infinite possibilities. I would suggest posting all your code or at least a breakdown UML diagram of what is going on in your entire program.

  • How can I made thirdparty JDBC-driver to be available under J2SDK?

    I have J2SDK installed into directory C:\j2sdk1.4.2_07
    OS is WinXP
    I compiled simple example java-file that accesses a mySql-DB
    It uses following line
    Class.forName("com.mysql.jdbc.Driver")
    But the result if it is
    ClassNotFoundException: com.mysql.jdbc.Driver
    SQLException: No suitable driver
    How can I made this calls to be available for the system?
    I have downloaded him in a jar-file from mysql-site and kopied into
    C:\j2sdk1.4.2_07\lib directory, but thet doesn't help
    What am I supposed to do?

    Another two tries and again no success:
    C:\j2sdk1.4.2_07\bin>java -classpath t:\yura\mysql-connector-java-3.1.10-bin.jar;.CreateCoffees
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    C:\j2sdk1.4.2_07\bin>java -classpath t:\yura\mysql-connector-java-3.1.10-bin.jar; .CreateCoffees
    Exception in thread "main" java.lang.NoClassDefFoundError: /CreateCoffees
    The difference between two commands is a space between ; and a dot(.)

  • How do I get the old java version (the one that worked) back

    I just did the lastest OSX upgrade.  OSX 10.7.   It did a few things to Java.
    1) It removed the Utility to select a Java version to run (umm, so how am I supposed to pick Java 1.5 for some old Java 1.5 apps?)
    2) It made some Java 1.6 applications that I need on my desktop to do my job not work.   Anyone heard of ScrumWorksPro.?  Barfing on a laf.jar that's missing from the new 1.6 version
    I can't seem to 'downgrade' back to the version that worked.   Does anyone have the zip file of the old version of Java that worked?  If so, where do I unzip it to.   I'm fine with launching my app from a terminal, I just need the jvm files so I can.  Looks like the installer (or my attempts to get rid of the new version by doing rm -r on every Java dir I could find) has gotten rid of the old version of Java.   I just can't seem to find the installer or the zip files to get the old version.
    Help!

    In Firefox 4 by default the Stop, Go and Reload (refresh) buttons are combined and attached to the right hand edge of the location bar.
    When you are typing in the location bar it will show the Go button. When a site is loading it shows the Stop button. At other times it shows the Reload button.
    If you want separate buttons, Control-click on a toolbar and choose Customize, you can then drag and drop the stop or reload buttons and place them elsewhere. If you place them in the order "Reload-Stop" on the right hand edge of the location bar they will be combined again. For more details on customizing the toolbar see https://support.mozilla.com/kb/How+to+customize+the+toolbar

  • How to print a text in java?

    How to print a text in java?

    of corse, i have JTextField in my frame that i want to extract the text and print it on a paper with a printer.

  • How to open new webBrowser in java with BrowserLauncher.java

    I m using BrowserLauncher.java which opens default webBrowser but i want to open new webBrowser for new request each time.
    Plz suggest to me what changes i have to made in this java class.
    it is very urgent???
    package com.pst.lmsgui.utils;
    import java.io.File;
    import java.io.IOException;
    import java.lang.reflect.Constructor;
    import java.lang.reflect.Field;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    * BrowserLauncher is a class that provides one static method, openURL, which opens the default
    * web browser for the current user of the system to the given URL. It may support other
    * protocols depending on the system -- mailto, ftp, etc. -- but that has not been rigorously
    * tested and is not guaranteed to work.
    * <p>
    * Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms
    * that are not part of the standard JDK. What we're trying to do, though, is to take something
    * that's frequently desirable but inherently platform-specific -- opening a default browser --
    * and allow programmers (you, for example) to do so without worrying about dropping into native
    * code or doing anything else similarly evil.
    * <p>
    * Anyway, this code is completely in Java and will run on all JDK 1.1(or better)-compliant systems without
    * modification or a need for additional libraries. All classes that are required on certain
    * platforms to allow this to run are dynamically loaded at runtime via reflection and, if not
    * found, will not cause this to do anything other than returning an error when opening the
    * browser.
    * <p>
    * There are certain system requirements for this class, as it's running through Runtime.exec(),
    * which is Java's way of making a native system call. Currently, this requires that a Macintosh
    * have a Finder which supports the GURL event, which is true for Mac OS 8.0 and 8.1 systems that
    * have the Internet Scripting AppleScript dictionary installed in the Scripting Additions folder
    * in the Extensions folder (which is installed by default as far as I know under Mac OS 8.0 and
    * 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems
    * (Windows 95, 98, and NT 4.0, as well as later versions of all). On other systems, this drops
    * back from the inherently platform-sensitive concept of a default browser and simply attempts
    * to launch Netscape via a shell command.
    * <p>
    * This code is Copyright 1999 by Eric Albert ([email protected]) and may be redistributed
    * or modified in any form without restrictions as long as the portion of this comment from this
    * paragraph through the end of the comment is not removed. The author requests that he be
    * notified of any application, applet, or other binary that makes use of this code, but that's
    * more out of curiosity than anything and is not required. This software includes no warranty.
    public class BrowserLauncher
    * The Java virtual machine that we are running on. Actually, in most cases we only care
    * about the operating system, but some operating systems require us to switch on the VM. */
    private static int jvm;
    /** The browser for the system */
    private static Object browser;
    * Caches whether any classes, methods, and fields that are not part of the JDK and need to
    * be dynamically loaded at runtime loaded successfully.
    * <p>
    * Note that if this is <code>false</code>, <code>openURL()</code> will always return an
    * IOException.
    private static boolean loadedWithoutErrors;
    /** The com.apple.mrj.MRJFileUtils class */
    private static Class mrjFileUtilsClass;
    /** The com.apple.mrj.MRJOSType class */
    private static Class mrjOSTypeClass;
    /** The com.apple.MacOS.MacOSError class */
    private static Class macOSErrorClass;
    /** The com.apple.MacOS.AEDesc class */
    private static Class aeDescClass;
    /** The <init>(int) method of com.apple.MacOS.AETarget */
    private static Constructor aeTargetConstructor;
    /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */
    private static Constructor appleEventConstructor;
    /** The <init>(String) method of com.apple.MacOS.AEDesc */
    private static Constructor aeDescConstructor;
    /** The findFolder method of com.apple.mrj.MRJFileUtils */
    private static Method findFolder;
    /** The getFileType method of com.apple.mrj.MRJOSType */
    private static Method getFileType;
    /** The makeOSType method of com.apple.MacOS.OSUtils */
    private static Method makeOSType;
    /** The putParameter method of com.apple.MacOS.AppleEvent */
    private static Method putParameter;
    /** The sendNoReply method of com.apple.MacOS.AppleEvent */
    private static Method sendNoReply;
    /** Actually an MRJOSType pointing to the System Folder on a Macintosh */
    private static Object kSystemFolderType;
    /** The keyDirectObject AppleEvent parameter type */
    private static Integer keyDirectObject;
    /** The kAutoGenerateReturnID AppleEvent code */
    private static Integer kAutoGenerateReturnID;
    /** The kAnyTransactionID AppleEvent code */
    private static Integer kAnyTransactionID;
    /** JVM constant for MRJ 2.0 */
    private static final int MRJ_2_0 = 0;
    /** JVM constant for MRJ 2.1 or later */
    private static final int MRJ_2_1 = 1;
    /** JVM constant for any Windows 9x JVM */
    private static final int WINDOWS_9x = 2;
    /** JVM constant for any Windows NT JVM */
    private static final int WINDOWS_NT = 3;
    /** JVM constant for any other platform */
    private static final int OTHER = -1;
    * The file type of the Finder on a Macintosh. Hardcoding "Finder" would keep non-U.S. English
    * systems from working properly.
    private static final String FINDER_TYPE = "FNDR";
    * The creator code of the Finder on a Macintosh, which is needed to send AppleEvents to the
    * application.
    private static final String FINDER_CREATOR = "MACS";
    /** The name for the AppleEvent type corresponding to a GetURL event. */
    private static final String GURL_EVENT = "GURL";
    * The first parameter that needs to be passed into Runtime.exec() to open the default web
    * browser on Windows.
    private static final String FIRST_WINDOWS_PARAMETER = "/c";
    /** The second parameter for Runtime.exec() on Windows. */
    private static final String SECOND_WINDOWS_PARAMETER = "start";
    * The shell parameters for Netscape that opens a given URL in an already-open copy of Netscape
    * on many command-line systems.
    private static final String NETSCAPE_OPEN_PARAMETER_START = " -remote openURL(";
    private static final String NETSCAPE_OPEN_PARAMETER_END = ")";
    * The message from any exception thrown throughout the initialization process.
    private static String errorMessage;
    * An initialization block that determines the operating system and loads the necessary
    * runtime data.
    static
    loadedWithoutErrors = true;
    String osName = System.getProperty("os.name");
    if ("Mac OS".equals(osName))
    String mrjVersion = System.getProperty("mrj.version");
    String majorMRJVersion = mrjVersion.substring(0, 3);
    try
    double version =
    Double.valueOf(majorMRJVersion).doubleValue();
    if (version == 2)
    jvm = MRJ_2_0;
    else if (version >= 2.1)
    // For the time being, assume that all post-2.0 versions of MRJ work the same
    jvm = MRJ_2_1;
    else
    loadedWithoutErrors = false;
    errorMessage = "Unsupported MRJ version: " + version;
    catch (NumberFormatException nfe)
    loadedWithoutErrors = false;
    errorMessage = "Invalid MRJ version: " + mrjVersion;
    else if (osName.startsWith("Windows"))
    { //still needs verification against Win2K
    if (osName.indexOf("9") != -1)
    jvm = WINDOWS_9x;
    else
    jvm = WINDOWS_NT;
    else
    jvm = OTHER;
    if (loadedWithoutErrors)
    { // if we haven't hit any errors yet
    loadedWithoutErrors = loadClasses();
    * This class should be never be instantiated; this just ensures so.
    BrowserLauncher()
    * Called by a static initializer to load any classes, fields, and methods required at runtime
    * to locate the user's web browser.
    * @return <code>true</code> if all intialization succeeded
    *               <code>false</code> if any portion of the initialization failed
    private static boolean loadClasses()
    switch (jvm)
    case MRJ_2_0:
    try
    Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
    macOSErrorClass = Class.forName("com.apple.MacOS.MacOSError");
    Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
    Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
    Class aeClass = Class.forName("com.apple.MacOS.ae");
    aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
    aeTargetConstructor =
    aeTargetClass.getDeclaredConstructor(
    new Class []{ int.class });
    appleEventConstructor =
    appleEventClass.getDeclaredConstructor(
    new Class[]{ int.class, int.class,
    aeTargetClass, int.class, int.class });
    aeDescConstructor = aeDescClass.getDeclaredConstructor(
    new Class[]{ String.class });
    makeOSType =
    osUtilsClass.getDeclaredMethod("makeOSType",
    new Class []{ String.class });
    putParameter =
    appleEventClass.getDeclaredMethod("putParameter",
    new Class[]{ int.class, aeDescClass });
    sendNoReply =
    appleEventClass.getDeclaredMethod("sendNoReply",
    new Class[]{ });
    Field keyDirectObjectField =
    aeClass.getDeclaredField("keyDirectObject");
    keyDirectObject =
    (Integer) keyDirectObjectField.get(null);
    Field autoGenerateReturnIDField =
    appleEventClass.getDeclaredField("kAutoGenerateReturnID");
    kAutoGenerateReturnID =
    (Integer) autoGenerateReturnIDField.get(null);
    Field anyTransactionIDField =
    appleEventClass.getDeclaredField("kAnyTransactionID");
    kAnyTransactionID =
    (Integer) anyTransactionIDField.get(null);
    catch (ClassNotFoundException cnfe)
    errorMessage = cnfe.getMessage();
    return false;
    catch (NoSuchMethodException nsme)
    errorMessage = nsme.getMessage();
    return false;
    catch (NoSuchFieldException nsfe)
    errorMessage = nsfe.getMessage();
    return false;
    catch (IllegalAccessException iae)
    errorMessage = iae.getMessage();
    return false;
    break;
    case MRJ_2_1:
    try
    mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
    mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType");
    Field systemFolderField =
    mrjFileUtilsClass.getDeclaredField("kSystemFolderType");
    kSystemFolderType = systemFolderField.get(null);
    findFolder =
    mrjFileUtilsClass.getDeclaredMethod("findFolder",
    new Class[]{ mrjOSTypeClass });
    getFileType =
    mrjFileUtilsClass.getDeclaredMethod("getFileType",
    new Class[]{ File.class });
    catch (ClassNotFoundException cnfe)
    errorMessage = cnfe.getMessage();
    return false;
    catch (NoSuchFieldException nsfe)
    errorMessage = nsfe.getMessage();
    return false;
    catch (NoSuchMethodException nsme)
    errorMessage = nsme.getMessage();
    return false;
    catch (SecurityException se)
    errorMessage = se.getMessage();
    return false;
    catch (IllegalAccessException iae)
    errorMessage = iae.getMessage();
    return false;
    break;
    return true;
    * Attempts to locate the default web browser on the local system. Caches results so it
    * only locates the browser once for each use of this class per JVM instance.
    * @return The browser for the system. Note that this may not be what you would consider
    *     to be a standard web browser; instead, it's the application that gets called to
    *     open the default web browser. In some cases, this will be a non-String object
    *     that provides the means of calling the default browser.
    private static Object locateBrowser()
    if (browser != null)
    return browser;
    switch (jvm)
    case MRJ_2_0:
    try
    Integer finderCreatorCode =
    (Integer) makeOSType.invoke(null,
    new Object[]{ FINDER_CREATOR });
    Object aeTarget = aeTargetConstructor.newInstance(
    new Object[]{ finderCreatorCode });
    Integer gurlType = (Integer) makeOSType.invoke(null,
    new Object[]{ GURL_EVENT });
    Object appleEvent = appleEventConstructor.newInstance(
    new Object[]{ gurlType, gurlType, aeTarget,
    kAutoGenerateReturnID, kAnyTransactionID });
    // Don't set browser = appleEvent because then the next time we call
    // locateBrowser(), we'll get the same AppleEvent, to which we'll already have
    // added the relevant parameter. Instead, regenerate the AppleEvent every time.
    // There's probably a way to do this better; if any has any ideas, please let
    // me know.
    return appleEvent;
    catch (IllegalAccessException iae)
    browser = null;
    errorMessage = iae.getMessage();
    return browser;
    catch (InstantiationException ie)
    browser = null;
    errorMessage = ie.getMessage();
    return browser;
    catch (InvocationTargetException ite)
    browser = null;
    errorMessage = ite.getMessage();
    return browser;
    case MRJ_2_1:
    File systemFolder;
    try
    systemFolder = (File) findFolder.invoke(null,
    new Object[]{ kSystemFolderType });
    catch (IllegalArgumentException iare)
    browser = null;
    errorMessage = iare.getMessage();
    return browser;
    catch (IllegalAccessException iae)
    browser = null;
    errorMessage = iae.getMessage();
    return browser;
    catch (InvocationTargetException ite)
    browser = null;
    errorMessage = ite.getTargetException().getClass() +
    ": " + ite.getTargetException().getMessage();
    return browser;
    String[] systemFolderFiles = systemFolder.list();
    // Avoid a FilenameFilter because that can't be stopped mid-list
    for (int i = 0; i < systemFolderFiles.length; i++)
    try
    File file = new File(systemFolder,
    systemFolderFiles);
    if (!file.isFile())
    continue;
    Object fileType = getFileType.invoke(null,
    new Object[]{ file });
    if (FINDER_TYPE.equals(fileType.toString()))
    browser = file.toString(); // Actually the Finder, but that's OK
    return browser;
    catch (IllegalArgumentException iare)
    browser = browser;
    errorMessage = iare.getMessage();
    return null;
    catch (IllegalAccessException iae)
    browser = null;
    errorMessage = iae.getMessage();
    return browser;
    catch (InvocationTargetException ite)
    browser = null;
    errorMessage = ite.getTargetException().getClass() +
    ": " + ite.getTargetException().
    getMessage();
    return browser;
    browser = null;
    break;
    case WINDOWS_NT:
    browser = "cmd.exe";
    break;
    case WINDOWS_9x:
    browser = "command.com";
    break;
    case OTHER: //fall through
    default:
    browser = "netscape";
    break;
    return browser;
    * Attempts to open the default web browser to the given URL.
    * @param url The URL to open
    * @throws IOException If the web browser could not be located or does not run
    public static void openURL(String url) throws IOException
    if (!loadedWithoutErrors)
    throw new IOException("Exception in finding browser: " +
    errorMessage);
    Object browser = locateBrowser();
    if (browser == null)
    throw new IOException("Unable to locate browser: " +
    errorMessage);
    switch (jvm)
    case MRJ_2_0:
    Object aeDesc = null;
    try
    aeDesc = aeDescConstructor.newInstance(
    new Object[]{ url });
    putParameter.invoke(browser,
    new Object[]{ keyDirectObject, aeDesc });
    sendNoReply.invoke(browser, new Object[]{ });
    catch (InvocationTargetException ite)
    throw new IOException(
    "InvocationTargetException while creating AEDesc: " +
    ite.getMessage());
    catch (IllegalAccessException iae)
    throw new IOException(
    "IllegalAccessException while building AppleEvent: " +
    iae.getMessage());
    catch (InstantiationException ie)
    throw new IOException(
    "InstantiationException while creating AEDesc: " +
    ie.getMessage());
    finally { aeDesc = null; // Encourage it to get disposed if it was created
    browser = null; // Ditto
    } break;
    case MRJ_2_1:
    Runtime.getRuntime().exec(
    new String[]{ (String) browser, url });
    break;
    case WINDOWS_NT://fall through
    case WINDOWS_9x:
    Runtime.getRuntime().exec( new String[]{ (String) browser,
    FIRST_WINDOWS_PARAMETER,
    SECOND_WINDOWS_PARAMETER, url });
    break;
    case OTHER:
    // Assume that we're on Unix and that Netscape is installed
    // First, attempt to open the URL in a currently running session of Netscape
    Process process =
    Runtime.getRuntime().exec((String) browser +
    NETSCAPE_OPEN_PARAMETER_START + url +
    NETSCAPE_OPEN_PARAMETER_END);
    try
    int exitCode = process.waitFor();
    if (exitCode != 0)
    { // if Netscape was not open
    Runtime.getRuntime().exec(
    new String[]{ (String) browser, url });
    catch (InterruptedException ie)
    throw new IOException(
    "InterruptedException while launching browser: " +
    ie.getMessage());
    break;
    default:
    // This should never occur, but if it does, we'll try the simplest thing possible
    Runtime.getRuntime().exec(
    new String[]{ (String) browser, url });
    break;
    // Driver to test class
    public static void main(String[] args) throws IOException
         BrowserLauncher br = new BrowserLauncher();
    if (args.length != 1)
    br.openURL("http://mail.lionbridge.com");
    else
    br.openURL(args[0]);

    package com.pst.lmsgui.utils;
    import java.io.File;
    import java.io.IOException;
    import java.lang.reflect.Constructor;
    import java.lang.reflect.Field;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    * BrowserLauncher is a class that provides one static method, openURL, which opens the default
    * web browser for the current user of the system to the given URL. It may support other
    * protocols depending on the system -- mailto, ftp, etc. -- but that has not been rigorously
    * tested and is not guaranteed to work.
    * Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms
    * that are not part of the standard JDK. What we're trying to do, though, is to take something
    * that's frequently desirable but inherently platform-specific -- opening a default browser --
    * and allow programmers (you, for example) to do so without worrying about dropping into native
    * code or doing anything else similarly evil.
    * Anyway, this code is completely in Java and will run on all JDK 1.1(or better)-compliant systems without
    * modification or a need for additional libraries. All classes that are required on certain
    * platforms to allow this to run are dynamically loaded at runtime via reflection and, if not
    * found, will not cause this to do anything other than returning an error when opening the
    * browser.
    * There are certain system requirements for this class, as it's running through Runtime.exec(),
    * which is Java's way of making a native system call. Currently, this requires that a Macintosh
    * have a Finder which supports the GURL event, which is true for Mac OS 8.0 and 8.1 systems that
    * have the Internet Scripting AppleScript dictionary installed in the Scripting Additions folder
    * in the Extensions folder (which is installed by default as far as I know under Mac OS 8.0 and
    * 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems
    * (Windows 95, 98, and NT 4.0, as well as later versions of all). On other systems, this drops
    * back from the inherently platform-sensitive concept of a default browser and simply attempts
    * to launch Netscape via a shell command.
    * This code is Copyright 1999 by Eric Albert ([email protected]) and may be redistributed
    * or modified in any form without restrictions as long as the portion of this comment from this
    * paragraph through the end of the comment is not removed. The author requests that he be
    * notified of any application, applet, or other binary that makes use of this code, but that's
    * more out of curiosity than anything and is not required. This software includes no warranty.
    public class BrowserLauncher {
    * The Java virtual machine that we are running on. Actually, in most cases we only care
    * about the operating system, but some operating systems require us to switch on the VM.
    private static int jvm; /** The browser for the system */
    private static Object browser;
    * Caches whether any classes, methods, and fields that are not part of the JDK and need to
    * be dynamically loaded at runtime loaded successfully.
    * Note that if this is <code>false</code>, <code>openURL()</code> will always return an
    * IOException.
    private static boolean loadedWithoutErrors; /** The com.apple.mrj.MRJFileUtils class */
    private static Class mrjFileUtilsClass; /** The com.apple.mrj.MRJOSType class */
    private static Class mrjOSTypeClass; /** The com.apple.MacOS.MacOSError class */
    private static Class macOSErrorClass; /** The com.apple.MacOS.AEDesc class */
    private static Class aeDescClass; /** The <init>(int) method of com.apple.MacOS.AETarget */
    private static Constructor aeTargetConstructor; /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */
    private static Constructor appleEventConstructor; /** The <init>(String) method of com.apple.MacOS.AEDesc */
    private static Constructor aeDescConstructor; /** The findFolder method of com.apple.mrj.MRJFileUtils */
    private static Method findFolder; /** The getFileType method of com.apple.mrj.MRJOSType */
    private static Method getFileType; /** The makeOSType method of com.apple.MacOS.OSUtils */
    private static Method makeOSType; /** The putParameter method of com.apple.MacOS.AppleEvent */
    private static Method putParameter; /** The sendNoReply method of com.apple.MacOS.AppleEvent */
    private static Method sendNoReply; /** Actually an MRJOSType pointing to the System Folder on a Macintosh */
    private static Object kSystemFolderType; /** The keyDirectObject AppleEvent parameter type */
    private static Integer keyDirectObject; /** The kAutoGenerateReturnID AppleEvent code */
    private static Integer kAutoGenerateReturnID; /** The kAnyTransactionID AppleEvent code */
    private static Integer kAnyTransactionID; /** JVM constant for MRJ 2.0 */
    private static final int MRJ_2_0 = 0; /** JVM constant for MRJ 2.1 or later */
    private static final int MRJ_2_1 = 1; /** JVM constant for any Windows 9x JVM */
    private static final int WINDOWS_9x = 2; /** JVM constant for any Windows NT JVM */
    private static final int WINDOWS_NT = 3; /** JVM constant for any other platform */
    private static final int OTHER = -1; /** * The file type of the Finder on a Macintosh. Hardcoding "Finder" would keep non-U.S. English * systems from working properly. */
    private static final String FINDER_TYPE = "FNDR"; /** * The creator code of the Finder on a Macintosh, which is needed to send AppleEvents to the * application. */
    private static final String FINDER_CREATOR = "MACS"; /** The name for the AppleEvent type corresponding to a GetURL event. */
    private static final String GURL_EVENT = "GURL"; /** * The first parameter that needs to be passed into Runtime.exec() to open the default web * browser on Windows. */
    private static final String FIRST_WINDOWS_PARAMETER = "/c"; /** The second parameter for Runtime.exec() on Windows. */
    private static final String SECOND_WINDOWS_PARAMETER = "start";
    * The shell parameters for Netscape that opens a given URL in an already-open copy of Netscape
    * on many command-line systems.
    private static final String NETSCAPE_OPEN_PARAMETER_START = " -remote openURL(";
    private static final String NETSCAPE_OPEN_PARAMETER_END = ")"; /** * The message from any exception thrown throughout the initialization process. */
    private static String errorMessage; /** * An initialization block that determines the operating system and loads the necessary * runtime data. */
    static {
    loadedWithoutErrors = true;
    String osName = System.getProperty("os.name");
    if ("Mac OS".equals(osName)) {
    String mrjVersion = System.getProperty("mrj.version");
    String majorMRJVersion = mrjVersion.substring(0, 3);
    try {
    double version = Double.valueOf(majorMRJVersion).doubleValue();
    if (version == 2) {
    jvm = MRJ_2_0;
    } else if (version >= 2.1) { // For the time being, assume that all post-2.0 versions of MRJ work the same
    jvm = MRJ_2_1;
    } else {
    loadedWithoutErrors = false;
    errorMessage = "Unsupported MRJ version: " + version;
    } catch (NumberFormatException nfe) {
    loadedWithoutErrors = false;
    errorMessage = "Invalid MRJ version: " + mrjVersion;
    } else if (osName.startsWith("Windows")) { //still needs verification against Win2K
    if (osName.indexOf("9") != -1) {
    jvm = WINDOWS_9x;
    } else {
    jvm = WINDOWS_NT;
    } else {
    jvm = OTHER;
    if (loadedWithoutErrors) { // if we haven't hit any errors yet
    loadedWithoutErrors = loadClasses();
    } /** * This class should be never be instantiated; this just ensures so. */
    BrowserLauncher() { }
    * Called by a static initializer to load any classes, fields, and methods required at runtime * to locate the user's web browser.
    * @return <code>true</code> if all intialization succeeded * <code>false</code> if any portion of the initialization failed */
    private static boolean loadClasses() {
    switch (jvm) {
    case MRJ_2_0:
    try {
    Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
    macOSErrorClass = Class.forName("com.apple.MacOS.MacOSError");
    Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
    Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
    Class aeClass = Class.forName("com.apple.MacOS.ae");
    aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
    aeTargetConstructor = aeTargetClass.getDeclaredConstructor( new Class []{ int.class });
    appleEventConstructor = appleEventClass.getDeclaredConstructor( new Class[]{ int.class, int.class, aeTargetClass, int.class, int.class });
    aeDescConstructor = aeDescClass.getDeclaredConstructor( new Class[]{ String.class });
    makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class []{ String.class });
    putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[]{ int.class, aeDescClass });
    sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[]{ });
    Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject");
    keyDirectObject = (Integer) keyDirectObjectField.get(null);
    Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID");
    kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null);
    Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID");
    kAnyTransactionID = (Integer) anyTransactionIDField.get(null);
    } catch (ClassNotFoundException cnfe) {
    errorMessage = cnfe.getMessage();
    return false;
    } catch (NoSuchMethodException nsme) {
    errorMessage = nsme.getMessage();
    return false;
    } catch (NoSuchFieldException nsfe) {
    errorMessage = nsfe.getMessage();
    return false;
    } catch (IllegalAccessException iae) {
    errorMessage = iae.getMessage();
    return false;
    } break;
    case MRJ_2_1:
    try {
    mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
    mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType");
    Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType");
    kSystemFolderType = systemFolderField.get(null);
    findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[]{ mrjOSTypeClass });
    getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[]{ File.class });
    } catch (ClassNotFoundException cnfe) {
    errorMessage = cnfe.getMessage();
    return false;
    } catch (NoSuchFieldException nsfe) {
    errorMessage = nsfe.getMessage();
    return false;
    } catch (NoSuchMethodException nsme) {
    errorMessage = nsme.getMessage();
    return false;
    } catch (SecurityException se) {
    errorMessage = se.getMessage();
    return false;
    } catch (IllegalAccessException iae) {
    errorMessage = iae.getMessage();
    return false;
    break;
    return true;
    * Attempts to locate the default web browser on the local system. Caches results so it
    * only locates the browser once for each use of this class per JVM instance.
    * @return The browser for the system. Note that this may not be what you would consider
    * to be a standard web browser; instead, it's the application that gets called to
    * open the default web browser. In some cases, this will be a non-String object
    * that provides the means of calling the default browser.
    private static Object locateBrowser() {
    if (browser != null) {
    return browser;
    switch (jvm) {
    case MRJ_2_0:
    try {
    Integer finderCreatorCode = (Integer) makeOSType.invoke(null, new Object[]{ FINDER_CREATOR });
    Object aeTarget = aeTargetConstructor.newInstance( new Object[]{ finderCreatorCode });
    Integer gurlType = (Integer) makeOSType.invoke(null, new Object[]{ GURL_EVENT });
    Object appleEvent = appleEventConstructor.newInstance( new Object[]{ gurlType, gurlType, aeTarget, kAutoGenerateReturnID, kAnyTransactionID });
    // Don't set browser = appleEvent because then the next time we call
    // locateBrowser(), we'll get the same AppleEvent, to which we'll already have
    // added the relevant parameter. Instead, regenerate the AppleEvent every time.
    // There's probably a way to do this better; if any has any ideas, please let
    // me know.
    return appleEvent;
    } catch (IllegalAccessException iae) {
    browser = null;
    errorMessage = iae.getMessage();
    return browser;
    } catch (InstantiationException ie) {
    browser = null;
    errorMessage = ie.getMessage();
    return browser;
    } catch (InvocationTargetException ite) {
    browser = null;
    errorMessage = ite.getMessage();
    return browser;
    case MRJ_2_1:
    File systemFolder;
    try {
    systemFolder = (File) findFolder.invoke(null, new Object[]{ kSystemFolderType });
    } catch (IllegalArgumentException iare) {
    browser = null;
    errorMessage = iare.getMessage();
    return browser;
    } catch (IllegalAccessException iae) {
    browser = null;
    errorMessage = iae.getMessage();
    return browser;
    } catch (InvocationTargetException ite) {
    browser = null;
    errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage();
    return browser;
    String[] systemFolderFiles = systemFolder.list();
    // Avoid a FilenameFilter because that can't be stopped mid-list
    for (int i = 0; i < systemFolderFiles.length; i++) {
    try {
    File file = new File(systemFolder, systemFolderFiles);
    if (!file.isFile()) {
    continue;
    Object fileType = getFileType.invoke(null, new Object[]{ file });
    if (FINDER_TYPE.equals(fileType.toString())) {
    browser = file.toString();
    // Actually the Finder, but that's OK return browser;
    } catch (IllegalArgumentException iare) {
    browser = browser;
    errorMessage = iare.getMessage();
    return null;
    } catch (IllegalAccessException iae) {
    browser = null;
    errorMessage = iae.getMessage();
    return browser;
    } catch (InvocationTargetException ite) {
    browser = null;
    errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException(). getMessage();
    return browser;
    browser = null;
    break;
    case WINDOWS_NT:
    browser = "cmd.exe";
    break;
    case WINDOWS_9x:
    browser = "command.com";
    break;
    case OTHER: //fall through
    default:
    browser = "netscape";
    break;
    return browser;
    * Attempts to open the default web browser to the given URL.
    * @param url The URL to open
    * @throws IOException If the web browser could not be located or does not run
    public static void openURL(String url) throws IOException {
    if (!loadedWithoutErrors) {
    throw new IOException("Exception in finding browser: " + errorMessage);
    Object browser = locateBrowser();
    if (browser == null) {
    throw new IOException("Unable to locate browser: " + errorMessage);
    switch (jvm) {
    case MRJ_2_0:
    Object aeDesc = null;
    try {
    aeDesc = aeDescConstructor.newInstance( new Object[]{ url });
    putParameter.invoke(browser, new Object[]{ keyDirectObject, aeDesc });
    sendNoReply.invoke(browser, new Object[]{ });
    } catch (InvocationTargetException ite) {
    throw new IOException( "InvocationTargetException while creating AEDesc: " + ite.getMessage());
    } catch (IllegalAccessException iae) {
    throw new IOException( "IllegalAccessException while building AppleEvent: " + iae.getMessage());
    } catch (InstantiationException ie) {
    throw new IOException( "InstantiationException while creating AEDesc: " + ie.getMessage());
    } finally {
    aeDesc = null; // Encourage it to get disposed if it was created
    browser = null; // Ditto
    } break;
    case MRJ_2_1:
    Runtime.getRuntime().exec( new String[]{ (String) browser, url });
    break;
    case WINDOWS_NT://fall through
    case WINDOWS_9x:
    Runtime.getRuntime().exec( new String[]{ (String) browser, FIRST_WINDOWS_PARAMETER, SECOND_WINDOWS_PARAMETER, url });
    break;
    case OTHER: // Assume that we're on Unix and that Netscape is installed
    // First, attempt to open the URL in a currently running session of Netscape
    Process process = Runtime.getRuntime().exec((String) browser + NETSCAPE_OPEN_PARAMETER_START + url + NETSCAPE_OPEN_PARAMETER_END);
    try {
    int exitCode = process.waitFor();
    if (exitCode != 0) { // if Netscape was not open
    Runtime.getRuntime().exec( new String[]{ (String) browser, url });
    } catch (InterruptedException ie) {
    throw new IOException( "InterruptedException while launching browser: " + ie.getMessage());
    } break;
    default: // This should never occur, but if it does, we'll try the simplest thing possible
    Runtime.getRuntime().exec( new String[]{ (String) browser, url });
    break;
    // Driver to test class
    public static void main(String[] args) throws IOException {
    BrowserLauncher br = new BrowserLauncher();
    if (args.length != 1) br.openURL("http://199.233.155.110:8080");
    else br.openURL(args[0]);

  • How to compile and register a Java CFX tag with multiple class files?

    All-
    If this is the wrong forum for CFX questions, please let me
    know.
    I need to determine how to compile and register a Java CFX
    tag that contains multiple class files. One class file implements
    the CustomTag interface and the other class files implement various
    supporting classes. All of the documentation that I have found
    talks about using a single class file. I am assuming that a JAR
    file will be involved, but I am not sure of the specifics.
    Thanks in advance for your help.
    -Josh

    Yes, it will involve a jar. Use your java IDE (eclipse,
    etcetera ..) to create a jar containing all of the classes. Check
    your ide's documentation for how to create jar files. After you
    have created the jar, place the jar in the CF class path so CF will
    recognize it. For example the {cf_root}/WEB-INF/lib directory. CF
    must be restarted before it will detect the new jar. After
    restarting CF, register the CFX tag in the ColdFusion Administrator
    using the name of the class that implements the CustomTag
    interface.
    Though it is worth noting you can also instantiate java
    classes directly from ColdFusion (ie without using a CFX
    tag).

  • How to clear the screen in java?

    Hi,
    How to clear the screen in java without using any loops?
    Thanks

    Just paint with your background color to let the old paintings vanish.

  • How to change system time through java program

    Hi
    I want to know, how to change system time through java program.
    give me a idia with example.
    Thanks

    There isn't any core Java API for this. Use JNI or call an external process with Runtime.exec().
    ~

  • How to set proxy authentication using java properties at run time

    Hi All,
    How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
    => Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
    import java.io.*;
    import java.net.*;
    public class DnldURLWithoutUsingProxy {
       public static void main (String[] args) {
          URL u;
          InputStream is = null;
          DataInputStream dis;
          String s;
          try {
              u = new URL("http://www.yahoo.com.au/index.html");
             is = u.openStream();         // throws an IOException
             dis = new DataInputStream(new BufferedInputStream(is));
             BufferedReader br = new BufferedReader(new InputStreamReader(dis));
          String strLine;
          //Read File Line By Line
          while ((strLine = br.readLine()) != null)      {
          // Print the content on the console
              System.out.println (strLine);
          //Close the input stream
          dis.close();
          } catch (MalformedURLException mue) {
             System.out.println("Ouch - a MalformedURLException happened.");
             mue.printStackTrace();
             System.exit(1);
          } catch (IOException ioe) {
             System.out.println("Oops- an IOException happened.");
             ioe.printStackTrace();
             System.exit(1);
          } finally {
             try {
                is.close();
             } catch (IOException ioe) {
    }However, it generated the following message when run behind the firewall:
    cd C:\Documents and Settings\abc\DnldURL\build\classes
    java -cp . DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:320)
    at sun.net.www.http.HttpClient.New(HttpClient.java:315)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    I have also tried the command without much luck either:
    java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
    There is no problem pinging www.yahoo.com from this system.
    I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
    I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
    Java Control Panel - Use browser settings without success.
    Thanks,
    George

    Hi All,
    How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
    => Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
    import java.io.*;
    import java.net.*;
    public class DnldURLWithoutUsingProxy {
       public static void main (String[] args) {
          URL u;
          InputStream is = null;
          DataInputStream dis;
          String s;
          try {
              u = new URL("http://www.yahoo.com.au/index.html");
             is = u.openStream();         // throws an IOException
             dis = new DataInputStream(new BufferedInputStream(is));
             BufferedReader br = new BufferedReader(new InputStreamReader(dis));
          String strLine;
          //Read File Line By Line
          while ((strLine = br.readLine()) != null)      {
          // Print the content on the console
              System.out.println (strLine);
          //Close the input stream
          dis.close();
          } catch (MalformedURLException mue) {
             System.out.println("Ouch - a MalformedURLException happened.");
             mue.printStackTrace();
             System.exit(1);
          } catch (IOException ioe) {
             System.out.println("Oops- an IOException happened.");
             ioe.printStackTrace();
             System.exit(1);
          } finally {
             try {
                is.close();
             } catch (IOException ioe) {
    }However, it generated the following message when run behind the firewall:
    cd C:\Documents and Settings\abc\DnldURL\build\classes
    java -cp . DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:320)
    at sun.net.www.http.HttpClient.New(HttpClient.java:315)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    I have also tried the command without much luck either:
    java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
    There is no problem pinging www.yahoo.com from this system.
    I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
    I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
    Java Control Panel - Use browser settings without success.
    Thanks,
    George

  • How to run ear file in java application server

    i want how to run .ear file in java application server
    1. i m created ear file
    2. i m created jar file (bean,home,remote)
    3.i m created war file(in the form of jsp)
    but till now i couldnt run ear file
    how to run
    please hel me

    You must create :
    1.Jar file
    2.War file
    And then put them into an ear file
    Exemple : myapp.ear contains
    myappEJB.jar
    myappWEB.war
    META-INF/application.xml
    and application.xml looks like this :
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
        <display-name>myapp</display-name>
        <description>Demo application</description>
        <module>
            <ejb>myappEJB.jar</ejb>
        </module>
        <module>
          <web>
             <web-uri>myappWAR.war</web-uri>
             <context-root>/myapp</context-root>
          </web>
        </module>
    </application>Good luck

  • How To Read RTF file in JAVA?  Using  iText?

    How To Read RTF file in JAVA?  Using  iText?.....
    import java.io.*;
    import com.lowagie.text.*;
    import com.lowagie.text.rtf.*;
    public class RTF3 {
    public static void main(String[] args) {
    // System.out.println("This example generate a RTF file name Sample.rtf");
    // Create Document object
    Document myDoc = new Document();
    try {
    // Create writer to listen document object
    // and directs RTF Stream to the file Sample.rtf
    RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));
    // open the document object
    myDoc.open();
    // Create a paragraph
         Paragraph p = new Paragraph();
         p.add("Helloworld in Rtf file..amazing isn't");
         // Add the paragraph to document object
    myDoc.add(p);
    catch(Exception e) {
    System.out.println(e);
    //close the document
    myDoc.close();
    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
         at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
         at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
         at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
         at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
         at com.lowagie.text.Document.open(Unknown Source)
         at view.RTF3.main(RTF3.java:23)
    CAN you HELP me?

    import com.lowagie.text.Document;
    import com.lowagie.text.rtf.parser.RtfParser;
    import java.io.FileInputStream;
    String inputFile = "sample.rtf";
    Document document = new Document();
    document.open();
    RtfParser parser = new RtfParser(null);
    parser.convertRtfDocument(new FileInputStream(inputFile), document);

  • How to use sql query in java ?

    i don't know how to use sql query in java code.
    who can give me some advice?
    thanks

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • How to create web services in java?

    Hi,
    I am a newbie to java webservices. Can anybody tell me how to create web services in java?
    Any tutorial link or step by step doc would be useful.
    Appreciate your help in this regard.
    Thanks in advance.
    naymo01.

    Creating web services in Java appears to depend highly upon the server you intend to use.
    Here's a tutorial: http://java.sun.com/webservices/docs/1.6/tutorial/doc/index.html

Maybe you are looking for

  • Aluminum Apple Remote not working well with Keynote '09 v.5.0.4

    I have an i7 17" MBP and I purchased the aluminum remote to go with it. I do training/presentations for a living and generally halfway through various presentations, the remote will stop controlling them. Sometimes if I restart Keynote it will work a

  • Are Library/Receipts files needed?

    I have a lot of files in my HD/Library/Receipts directory that are taking up a lot of space. Is it OK if I delete them? Thanks, Stew

  • CME 4.0 to Voice Gateway

    I have a 2600XM running CME 4.0 and a 1760 with 2 FX0 and 1 FXS card. Both routers are running IOS 10.4(9)T. I would like the 1760 to act as a gateway using H.323. Can anyone advise me on how to set this up?

  • Highlight Boxes

    Is there a way to change the default color of the highlight boxes? I know how to change the caption boxes but haven't located a way to change the hightlight boxes.

  • OSX contant kernel panic. How do I fix this?

    I was using a machine that had only OSX.3.9 installed. It ran fine, then I wanted Classic compatibility and the ability to boot into OS9, so I installed OS9 and upgraded all the way up to OS9.2.2 Ever since installing OS9 I now get a kernel panic whe