Dot in the Path to the Class

Hi,
I am trying to run a program that has a "dot" in its path, i.e. /path/to/.dir/MyClass. It seems like JVM command line doesn't accept dot and it converts it to "/" from what I see on the output. Is there a way to enforce the command line to take the path to the class as is and not to convert "." to "/"?

Hi,
Yes, this is being run on a Linux system by `crond' which prompted a suspension that it wasn't being run at all. So I tried it manually on the command line and realized it doesn't recognize the path to the class.
java /home/myuser/.dir/MyClass
Exception in thread "main" java.lang.NoClassDefFoundException: /home/myuser//dir/MyClassRunning the class from the hidden directory works accordingly:
cd /home/myuser/.dir
java MyClass
/* Right output */I have also tried quotations around the path in no vain

Similar Messages

  • Get the relative path for java class

    How to get Relative path for java class which is inside in web-inf directory in webapps

    ajay.manchu wrote:
    Hi gimbal2,
    My Requirement is i need to run a java class from batch file,when i created batch file in that i need to mention the complete path of the java class,so instead of mentioning that i want to provide only java class name,thats why i asked that one..
    can u help me regarding that....
    Thanks in advanceI wonder how that would work then. Let's take a fictive example. You have a class com.mycompany.myapp.Foo. This would mean that the class is stored in some directory like this:
    c:/webrootdir/myapp/WEB-INF/classes/com/mycompany/myapp/Foo.classTo be able to run such a class from the commandline using Java, you would have to invoke this command:
    java -cp c:/webrootdir/myapp/WEB-INF/classes com.mycompany.myapp.FooHow would knowing the exact path to this class help you?

  • How to run a jar file which needs another jar to be in the class path

    Hi,
    I need to execute a jar, which needs another jar to be in the classpath.
    If I run like
    java -classpath <jar1 name> -jar <main jar>
    It is giving classnotfoundexception, where as the class is available in the <jar1 name>.
    so, currently I am doing like this
    In the manifest file i have given like
    Main-Class: <class name>
    Class-Path: <jar name> <jar name2>
    then it is running fine. But, if I want to change the jar location again I need to changed the manifest file.
    Is there any way to do this? Pls help me.

    How about
    java -cp jar1.jar;jar2.jar com.acme.MainClass
    You won't need to worry about the manifest file after that and you can make a bat files (or .sh file in *nix) for it.                                                                                                                                                                                                                                                                                                                                                                       

  • How to set the class path?-

    my forlder is :C:\Documents and Settings\india
    jdk is in:C:\Program Files\Java\jdk1.5.0_11\bin
    can any body can help me to create a classpath for my folder?

    An alternative - as stated in reply 2 in your other thread on this topic: http://forum.java.sun.com/thread.jspa?threadID=5170470 - is not to set the CLASSPATH environment variable at all. Use the -classpath switch instead.
    As the documentation linked to in that reply points out: "The class search path (more commonly known by the shorter name, "class path") can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable. The -classpath option is preferred because you can set it individually for each application without affecting other applications and without other applications modifying its value."
    As always, the documentation is worth reading; the available command line options worth using.

  • Stand alone class and the class path

    Hi,
    I have a simple Java project in Eclipse environment. The project has it's class path,
    that contains a jar file that I need to use.
    The project runs perfect in the Eclipse.
    Now, I need to take the main class out of my project, to function alone in another environment.
    My problem is that out of the environment, I don't know how the class should know that classpath.
    I moved that jar to the same folder that the class located in, but I don't know how to tell it that the jar is there.
    My goal is to run my standalone class from another java class.
    I'm afraid that examples in command environment wouldn't help me.
    Thanks a lot for any help !

    moshi wrote:
    I have a simple Java project in Eclipse environment. The project has it's class path,
    that contains a jar file that I need to use.Ok, so you have a class that you have written that depends on an external library. Fair enough.
    The project runs perfect in the Eclipse.
    Now, I need to take the main class out of my project, to function alone in another environment.Maybe (just maybe!) defining what exactly that "other environment" is could help us help you.
    My problem is that out of the environment, I don't know how the class should know that classpath.Well, obviously that depends on what that other environment is.
    You must have some way to influence that other environments classpath, or you couldn't even get it to call/use your class.
    I moved that jar to the same folder that the class located in, but I don't know how to tell it that the jar is there.Now you're just guessing.
    My goal is to run my standalone class from another java class. That's simple enough, you probably do it all the time.
    I'm afraid that examples in command environment wouldn't help me.And why exactly is that?
    Do you realize that you tell us far too little about your problem for us to be able to actually help you?

  • FindClass() not able to find the class in the same path

    Hi,
    I have a c prototype which calls a java function which push a message in JMS. i'm using jdk1.6. i have set JavaVMInitArgs vm_args.version = JNI_VERSION_1_6 when i compile the c code as gcc -g -lgcj -I $JAVA_HOME/include -I $JAVA_HOME/include/linux CallJMS.c the JNI_CreateJavaVM(&jvm, (void*)&env, &vm_args)* returns JNI_ERR. After changing version to 1.4 JavaVMInitArgs vm_args.version = JNI_VERSION_1_4 finally it gives me an executable which calls the java function (how ever the required functionality is not got)
    To get the required functionality i had to use jdk1.6 so i changed the version property to JNI_VERSION_1_6 and the compiling command as gcc -g CallJMS.c -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -L $JAVA_HOME/jre/lib/i386/server -ljvm .This gave me an executable, but when i execute it is not able to find the java class file. I have kept both the java and c file in the same path and also set the CLASSPATH. Please help.

    Hi jschell,
    I got solution to this problem. As you said it is due to wrong CLASSPATH set .
    Before:
    JavaVMInitArgs vm_args;
    JavaVMOption options[3];
    options[0].optionString = "-Djava.class.path=.:/home/programs/JbossMetro/jboss-5.1.0.GA/server/default/deploy/JMSforCNew.war/WEB-INF/classes";
    options[1].optionString="-Djava.library.path=.:/home/program/jdk1.6.0_23/jre/lib/i386/server";
    options[2].optionString="-verbose:jni";
    vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
    vm_args.nOptions = 3;
    vm_args.options = options;
    vm_args.ignoreUnrecognized = 0;
    int ret = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    if(ret < 0)
    printf("\nUnable to Launch JVM\n");
    else
    printf("\nLaunched JVM\n");
    I was setting the CLASSPATH to the Path where my java class files were kept. When the JVM instance is created only this path (where my java class is residing) is identified and the JMS and other paths which was already set in the CLASSPATH environment variable is lost. Thus when i call the java class from the c program it is not able to find the dependent class files and it was aborting.
    After:
    Before setting the path where my class files are residing to CLASSPATH, get the path's in the CLASSPATH to a variable, append the path where my class files are kept to this variable and then set the CLASSPATH . Similarly do for the LD_LIBRARY_PATH. This works fine.
    char cpathBuff[100000];
    char ldpathBuff[4096];
    JNIEnv *env;
    JavaVMInitArgs vm_args;
    JavaVMOption options[3];
    cpath = (char*) getenv("CLASSPATH");
    sprintf(cpathBuff,"%s%s:%s","-Djava.class.path=",cpath,"/home/programs/JbossMetro/jboss-5.1.0.GA/server/default/deploy/JMSforCNew.war/WEB-INF/classes");
    options[0].optionString = cpathBuff;
    ldpath = (char *)getenv("LD_LIBRARY_PATH");
    sprintf(ldpathBuff,"%s%s:%s","-Djava.library.path=",ldpath,"/home/program/jdk1.6.0_23/jre/lib/i386/server");
    options[1].optionString = ldpathBuff;
    vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
    vm_args.nOptions = 2;
    vm_args.options = options;
    vm_args.ignoreUnrecognized = 0;
    int ret = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    if(ret < 0)
    printf("\nUnable to Launch JVM\n");
    else
    printf("\nLaunched JVM\n");
    Thanks for your support Peter and JSchell.
    Edited by: 844094 on Mar 15, 2011 2:37 AM

  • Howto resolve the path to the class file

    hi @ all,
    i'm currently developing a package for ldap operations. now i want to write down all the real basic configuration for that package into a xml file which i want to save in the folder where the compiled class files are stored. my problem is that i do not know how i can resolve the absolute path to that xml file later. i mean, how can i load this file if the package is, e.g. exported as an jar file and i do not know where this jar file will be stored by the users of my package.
    can anyone help me with that please?
    thx in advance
    dialsc

    k, cool...
    looks like it goes into the right direction.
    with this statement i get the path where the jar is stored, right.
    in my current situation this is the path to the src directory which i configured my eclipse ide to store the class files under.
    let's say this path is d:\tmp\src
    my package is tdl.domain.utils.ldap
    so in fact at the moment my class files are stored under d:\tmp\src\tdl\domain\utils\ldap and the xml file too.
    first:
    that statement returns /D:/tmp/src
    as you can see it uses unix path separators. do i have to replace them with the machine specific pathSeparatorChar?
    second:
    can is simply add the path tdl\domain\utils\ldap to that one (using the according machine specific pathSeparatorChar) and will this also work when i build a jar file of my package?
    sorry for all that questions but i realy need this...
    thx
    dialsc

  • Class xyz is not in the class path

    When I used:
    <jsp:useBean id="blast" scope="session"class="hr.pbf.pnf.castorblast2.BlastOutput"/>
    (or other class) , I get an warning: "The class hr.pbf.pnf.castorblast2.BlastOutput" is not in the class path ???

    Hi,
    The possible reason could be that class is not present in project class path.
    Check the following location to make sure the project is configured with source and required libraries
    - Project > Properties > Java Build Path > Source Tab / Libraries Tab
    M7 Support

  • Simple question about environment variables and setting the class path???

    ok I have been trying for a few months now ontrying to set the class path..
    I work with windows vista..
    on the environment variables user variables,
    I have the name of the variable as class
    and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
    where javac is...
    on the system variables I have
    its name as class
    and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
    why is this not reading javac

    The PATH environment variable should have as an entry the directory containing your javac executable. The CLASSPATH should have have entries which define your library directories and entries which are your jar file libraries. In the early days, probably the only CLATHPATH entry you will need will be a '.' to indicate the current directory.
    The Java tutorial covers ALL of this.

  • Retrieve the class path!! need help

    Hi all
    I tried to retrieve the class path using the below method:
    URL srcUrl = ClassLoader.getSystemResource(fileName)
    Since the class path has some space in it, this srcUrl seems to be wrong
    the returned value would look like this, "%20" represnts the spaces in the path. So is there a way to avoid this, and to return the path correctly?
    D:\PROJECT\ReportDesigner\Run%20report%20designer%20from%20a%20share\
    thanks in advance
    madumm

    File srcDir = new File(srcUrl.getFile());Well you just can't do that, can you? URL.getFile() returns the filename part of the URL, but it's still URL-encoded. You have to convert each %20 to a space, and do a few other possible transformations as well. See java.net.URLDecoder.

  • Lost on the Class Path

    I'm having some serious trouble with class package path issues ... ugh!
    I've downloaded a fairly complex and well programmed FLA file and other source files in AS 3.0, and just started to adapt it for a custom application.  When I published the FLA and packages in FLash CS3, everything worked perfectly.  Then I just got Flash CS4 a few days ago, and so opened the same application in CS4, and also published it fine.  Yet, once I started to make some very simple customizations, such as create a new MovieClip, and then added "linkage" to the MovieClip in the library, the trouble started. Getting the new external class to associate to the new MovieClip was not working (although it was in the same location as the other package file, with the same class package designation), so of course I went to take a look at the preferences and set the general class path.  Interestingly, the class path was completely blank (I just installed CS4 that day).  Yet then, why was the application still working initially with no class path set?  All of your original classes were loading fine, and the application was working.  So, then when I went into actually set a class path (my new class is in the same folder: .../com/parkerandkent/components/classic/photogallery ), I start getting all kinds of errors ... and now, even if I revert back to having no class path at all, the application does not work at all (when it originally did with no class path at all).  Strange!  I am very confused about what is going on.
    There are 5 primary .as package files, all of which are linked to MovieClips in the Library:
    ClassicPhotoGallery.as
    Photo.as
    Thumb.as
    Thumbs.as
    CallTag.as (the new class)
    I've checked the properties linkage for each of these, and they all appear correct also.
    Currently, I have all of these class paths set:
       - "/Users/mac/_EXTRA/ArtMuse/GALLERY"
       - " "/Users/mac/_EXTRA/ArtMuse/GALLERY/com/parkerandkent/components/classic/photogallery"
    Currently, I get these these error messages, which are referring to only 3 of 5 total .as files (which are all in the same location, and all have the same class path designation - and none of these files is the new class I made, which now appears to be referenced okay).
    Photo.as Line 1:
    5001: The name of package 'com.parkerandkent.components.classic.photogallery' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. /Users/mac/_EXTRA/ArtMuse/GALLERY/com/parkerandkent/components/classic/photogallery/Photo .as
    Thumb.as Line 1:
    5001: The name of package 'com.parkerandkent.components.classic.photogallery' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. /Users/mac/_EXTRA/ArtMuse/GALLERY/com/parkerandkent/components/classic/photogallery/Thumb .as

    Again, the class path package designation is the same for all 5 .as files:
    package com.parkerandkent.components.classic.photogallery {
    yet the application is not working, and I get only those errors posted above.
    If I remove all source path designations, then I get NO error messages, and yet the application does not work (although, I swear it was working this way originally).

  • How can I find the real path to servlet class

    Hi,
    I am facing an issue. Am in the process of creating a filter which would send a Last-modified along with the header. For this I will be checking the is-modified-since
    header and lastModified date of the file.
    The problem I am facing is that after taking the file part from the request and checking
    the lastmodified date, it gives error. This is because i use,
    String real_path = getServletContext().getRealPath(request.getServletPath());
    and it would return the path to servlet-name and not to servlet-class, since servlet-name
    is not physically present. It would return an error value.
    Is there any way which I could find the real path to my servlet class file ?

    Remember you should not take the last mnodified date
    of the class file or the jar file that contain the
    class as the value for the getLastModified method
    becouse the last modified date that should be used in
    the caching is the last modified date of the dynamic
    content that the servlet is about to prodice.
    The same class file will produce different content
    for different requests if not why do you use
    servlets you can directly use the static contentThanks for a valuable remark.
    Hence our getLastModified() often returns System.currentTimeMillis() result.

  • How to programmatically get the source for a class provided the class name?

    Hello,
    As a quick background, I am providing some tools to potential users of an in-house framework. One is the ability to generate quick prototypes from our existing demo applications. Assume a user downloads our jars and uses them in their project (we are using Eclipse, but that detail should not greatly affect my question). Included in the jars is a demos package that contains ready-to-run classes that serve to exhibit certain functionality. Since many users may just need quick extensions of these demos, I am trying to provide a way for them to be able to create a new project that starts with a copy of the demo class.
    So, the user is provided a list of the existing demos (each one uses a single class). When the user makes their selection, with the knowledge of our framework, I can translate that into what demo class they need (returned as a string of format package.subpack1.subpackn.DemoClassName). What I now want to do is to use that complete class name to get the source (look up the file) for the corresponding class, and copy it into to a new file in their project (the copying into the project can be done easily in Eclipse, so what I need help with is the bolded part). Is there a simple way to get the source given a class path for a class as described above? You may assume the source files are included in the jars for the framework.
    Thanks in advance.

    If there's a file named "package.subpack1.subpackn.DemoClassName.java" in a "demos" directory in the jar, then yes. You'd just use
    InputStream code = getResourceAsStream("/demos.package.subpack1.subpackn.DemoClassName.java");Or if those dots in the name actually separate directory names, i.e. you have a "package" directory under "demos" and a "subpack1" director under that and so on, then:
    InputStream code = getResourceAsStream("/demos/package/subpack1/subpackn/DemoClassName.java");

  • Unable to load the class set in the humantask as a callback Class

    I am getting the below error when I set a class bpel.StockReview.MyCallback in my humantask as a callback on some update on the task. The class is getting packed with the jar properly and gets deployed to the server directory. However when I initiate the BPEL proc and run it, the class is notfound/ not laoded into the system. Below are the logs -
    <2009-04-27 15:19:09,207> <ERROR> <default.collaxa.cube.services> <::>      at java.lang.Class.forName0(Native Method)
    <2009-04-27 15:19:09,207> <ERROR> <default.collaxa.cube.services> <::>      at java.lang.Class.forName(Class.java:164)
    <2009-04-27 15:19:09,207> <ERROR> <default.collaxa.cube.services> <::>      at oracle.bpel.services.workflow.task.impl.RoutingSlipCallbackInvoker.executeJavaOnTaskCompleted(RoutingSlipCallbackInvoker.java:204)
    <2009-04-27 15:19:09,207> <ERROR> <default.collaxa.cube.services> <::>      ... 49 more
    <2009-04-27 15:19:09,207> <ERROR> <oracle.bpel.services.workflow> <::>
         Missing class: bpel.StockReview.MyCallback
         Dependent class: oracle.bpel.services.workflow.task.impl.RoutingSlipCallbackInvoker
         Loader: oracle.bpel.common:10.1.3
         Code-Source: /D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar
         Configuration: <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml
    This load was initiated at oracle.bpel.common:10.1.3 using the Class.forName() method.
    The missing class is not available from any code-source or loader in the system.
    oracle.classloader.util.AnnotatedClassNotFoundException:
         Missing class: bpel.StockReview.MyCallback
         Dependent class: oracle.bpel.services.workflow.task.impl.RoutingSlipCallbackInvoker
         Loader: oracle.bpel.common:10.1.3
         Code-Source: /D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar
         Configuration: <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml
    This load was initiated at oracle.bpel.common:10.1.3 using the Class.forName() method.
    The missing class is not available from any code-source or loader in the system.
         at oracle.classloader.PolicyClassLoader.handleClassNotFound (PolicyClassLoader.java:2068) [D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
         at oracle.classloader.PolicyClassLoader.internalLoadClass (PolicyClassLoader.java:1679) [D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
         at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1635) [D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
         at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1620) [D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
         at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:319) [jre bootstrap, by jre.bootstrap:1.5.0_06]
         at java.lang.Class.forName0 (Native method) [unknown, by unknown]
         at java.lang.Class.forName (Class.java:164) [jre bootstrap, by jre.bootstrap:1.5.0_06]
         at oracle.bpel.services.workflow.task.impl.RoutingSlipCallbackInvoker.executeJavaOnTaskCompleted (RoutingSlipCallbackInvoker.java:204) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.RoutingSlipCallbackInvoker.onTaskComplete (RoutingSlipCallbackInvoker.java:102) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.invokeCallbacks (TaskService.java:3096) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.performPostActionOperation (TaskService.java:3345) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.localHandleRoutingSlipInterpretationResult (TaskService.java:1239) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.handleRoutingSlipInterpretationResult (TaskService.java:1298) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.evaluateRoutingSlipTaskAssignment (TaskService.java:1173) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.updateTaskOutcomeAndEvaluateRoutingSlip (TaskService.java:1129) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.updateTaskOutcome (TaskService.java:941) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.impl.TaskService.updateTaskOutcome (TaskService.java:920) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at oracle.bpel.services.workflow.task.ejb.TaskServiceBean.updateTaskOutcome (TaskServiceBean.java:410) [D:/product_OAS/10.1.3.1/OracleAS_1/bpel/system/services/lib/bpm-services.jar (from <code-source> in /D:/product_OAS/10.1.3.1/OracleAS_1/j2ee/home/config/server.xml), by oracle.bpel.common:10.1.3]
         at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method) [unknown, by unknown]

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • How do I make a batch file if the .class file uses a foreign package?

    I am trying to make an MS-DOS batch file using the bytecode file from the Java source file, called AddFields.java. This program uses the package BreezySwing; which is not standard with the JDK. I had to download it seperately. I will come back to this batch file later.
    But first, in order to prove the concept, I created a Java file called Soap.java in JCreator. It is a very simple GUI program that uses the javax.swing package; which does come with the JDK. The JDK is currently stored in the following directory: C:\Program Files\Java\jdk1.6.0_07. I have the PATH environment variable set to the 'bin' folder of the JDK. I believe that it is important that this variable stay this way because C:\Program Files\Java\jdk1.6.0_07\bin is where the file 'java.exe' and 'javac.exe' are stored. Here is my batch file so far for Soap:
    @echo off
    cd \acorn
    set path=C:\Program Files\Java\jdk1.6.0_07\bin
    set classpath=.
    java Soap
    pause
    Before I ran this file, I compiled Soap.java in my IDE and then ran it successfully. Then I moved the .class file to the directory C:\acorn. I put NOTHING ELSE in this folder. then I told the computer where to find the file 'java.exe' which I know is needed for execution of the .class file. I put the above text in Notepad and then saved it as Soap.bat onto my desktop. When I double click on it, the command prompt comes up in a little green box for a few seconds, and then the GUI opens and says "It Works!". Now that I know the concept of batch files, I tried creating another one that used the BreezySwing package.
    After I installed my JDK, I installed BreezySwing and TerminalIO which are two foreign packages that make building code much easier. I downloaded the .zip file from Lambert and Osborne called BreezySwingAndTerminalIO.zip. I extracted the files to the 'bin' folder of my JDK. Once I did this, and set the PATH environment variable to the 'bin' folder of my JDK, all BreezySwing and TerminalIO programs that I made worked. Now I wanted to make a batch file from the program AddFields.java. It is a GUI program that imports two packages, the traditional GUI javax.swing package and the foreign package BreezySwing. The user enters two numbers in two DoubleField objects and then selects one of four buttons; one for each arithmetic operation (add, subtract, multiply, or divide). Then the program displays the solution in a third DoubleField object. This program both compiles and runs successfully in JCreator. So, next I moved the .class file from the MyProjects folder that JCreator uses to C:\acorn. I put nothing else in this folder. The file Soap.class was still in there, but I did not think it would matter. Then I created the batch file:
    @echo off
    cd \acorn
    set path=C:\Program Files\Java\jdk1.6.0_07\bin
    set classpath=.
    java AddFields
    pause
    As you can see, it is exactly the same as the one for Soap. I made this file in Notepad and called it AddFields.bat. Upon double clicking on the file, I got this error message from command prompt:
    Exception in thread "main" java.lang.NoClassDefFoundError: BreezySwing/GBFrame
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    4)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Caused by: java.lang.ClassNotFoundException: BreezySwing.GBFrame
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ... 12 more
    Press any key to continue . . .
    I know that most of this makes no sense; but that it only means that it cannot find the class BreezySwing or GBFrame (which AddFields extends). Notice, however that it does not give an error for javax.swing. If I change the "set path..." command to anything other than the 'bin' folder of my JDK, I get this error:
    'java' is not recognized as an internal or external command,
    operable program or batch file.
    Press any key to continue . . .
    I know this means that the computer cannot find the file 'java.exe' which I believe holds all of the java.x.y.z style packages (native packages); but not BreezySwing or any other foreign packages. Remember, I do not get this error for any of the native Java packages. I decided to compare the java.x.y.z packages with BreezySwing:
    I see that all of the native packages are not actually visible in the JDK's bin folder. I think that they are all stored in one of the .exe files in there because there are no .class files in the JDK's bin folder.
    However, BreezySwing is different, there is no such file called "BreezySwing.exe"; there are just about 20 .class files all with names like "GBFrame.class", and "GBActionListener.class". As a last effort, I moved all of these .class files directly into the bin folder (they were originally in a seperate folder called BreezySwingAndTerminalIO). This did nothing; even with all of the files in the same folder as java.exe.
    So my question is: What do I need to do to get the BreezySwing package recognized on my computer? Is there possibly a download for a file called "BreezySwing.exe" somewhere that would be similar to "java.exe" and contain all of the BreezySwing packages?

    There is a lot of detail in your posts. I won't properly quote everything you put (too laborious). Instead I'll just put your words inside quotes (").
    "..there are some things about the interface that I do not like."
    Like +what?+ This is not a help desk, and I would appreciate you participating in this discussion by providing details of what it is about the 'interface' of webstart that you 'do not like'. They are probably misunderstandings on your part.
    "Some of the .jar files I made were so dangerously corrupt, that I had to restart my computer before I could delete them."
    Corrupt?! I have never once had the Java tools produce a corrupt Jar. OTOH, the 'cannot delete' problem might relate to the JRE gaining a file lock on the archive at run-time. If the file lock persisted after ending the app., it suggests that the JRE was not properly shut down. This is a bug in the code and should be fixed. Deploying as .class files will only 'hide' the problem (from casual inspection - though the Task Manager should show the orphaned 'java' process).
    "I then turned to batch files for their simple structure and portability (I managed to successfully transport a java.util containing batch file from my computer to another). This was what I did:
    - I created a folder called Task
    - Then I copied three things into this folder: 1. The file "java.exe" from my JDK. 2. The program's .class file (Count.class). and 3. The original batch file.
    - Then I moved the folder from a removable disk to the second computer's C drive (C:\Task).
    - Last, I changed the code in the batch file...:"
    That is the +funniest+ thing I've heard on the forums in the last 72 hours. You say that is easy?! Some points.
    - editing batch files is not scalable to 100+ machines, let alone 10000+.
    - The fact that Java worked on the target machine was because it was +already installed.+ Dragging the 'java.exe' onto a Windows PC which has no Java will not magically make it 'Java enabled'.
    And speaking of Java on the client machine. Webstart has in-built mechanisms to ensure that the end user has the minimum required Java version to run the app. - we can also use the [deployJava.js|http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit] on the original web page, to check for minimum Java before it puts the link to download/install the app. - if the user does not have the required Java, the script should guide them through installing it.
    Those nice features in deployJava.js are available to applets and apps. launched using webstart, but they are not available for (plain) Jar's or loose class files. So if 'ensuring the user has Java' is one of the requirements for your launch, you are barking up the wrong tree by deploying loose class files.
    Note also that if you abandon webstart, but have your app. set up to work from a Jar, the installation process would be similar to above (though it would not need a .bat file, or editing it). This basic strategy is one way that I provide [Appleteer (as a downloadable ZIP archive)|http://pscode.org/appleteer/#download]. Though I side-step your part 1 by putting the stuff into a Jar with the path Appleteer/ - when the user expands the ZIP, the parts of the app. are already in the Appleteer directory.
    Appleteer is also provided as a webstart launched application (and as an applet). Either of those are 'easier' to use than the downloadable ZIP, but I thought I would provide it in case the end user wants to save it to disk and transport the app. to a machine with no internet connection, but with Java (why they would be testing applets on a PC with no internet connection, I am not sure - but the option is there).
    "I know that .jar and .exe files are out because I always get errors and I do not like their interfaces. "
    What on earth are you talking about? Once the app. is on-screen, the end user would not be able to distinguish between
    1) A Jar launched using a manifest.
    2) A Jar launched using webstart.
    3) Loose class files.
    Your fixation on .bat files sounds much like the adage that 'If the only tool you have is a hammer, every job starts to look like a nail'.
    Get over them, will you? +Using .bat files is not a practical way to provide a Java app. to the end user+ (and launching an app. from a .bat looks quite crappy and 'second hand' to +this+ user).
    Edit 1:
    The instructions for running Appleteer as a Jar are further up the page, in the [Running Appleteer: Application|http://pscode.org/appleteer/#application] section.
    Edited by: AndrewThompson64 on May 19, 2009 12:06 PM

Maybe you are looking for