.java files compile but cannot execute

Hello,-
I have a small problem in that the compiler can find the .java file (javac javaFile.java), however the execute command (java javaFile) does not work (Exception in thread "main" java.lang.NoClassDefFoundError: javaFile). I'm using Windows Vista and JDK 1.6.0_02. Which one of the environment variables is responsible for file execution?
Thanks beforehand, Vahagn

@ smithberry: Now it executes! Thanks for pointing that out and apologies for not seeing the space before the filename. But how come this is at all necessary? Do I have to run all my java programs with this command from now on, including the JUnit TestCase extensions?

Similar Messages

  • .java file compiling but not executing in jdk6

    Using javac in jdk6 I can compile a .java file but cant executing the same using java command from my own directory. I can still compile and execute the same file from jdk\bin directory. I am using windows XP Home. While executing the .java file from my own directory, it fires a message: "The Java class could not be loaded. java.lang.UnsupportedClassVersionError: Myfilename (Unsupported major.minor Version 50.0)". i have set path in environment variable as "C:\sun\sdk\jdk\bin" where jdk placed in sun\sdk.
    Please help me to solve the problem

    This isn't information we can give you. You have to set it up based on your system.
    Do you understand how execution paths work? There's a list of filesystem paths, separated by a semicolon or a colon depending on the system, all concatenated into one big string. The entries earlier in the string are looked in first.
    So if your path has this:
    c:\Windows\java;c:\sun\sdk\jdk\bin
    Then if you type "java" from the command line, the Windows one would be executed, not the JDK 6 one.

  • Can compile but cannot run.

    Dear Java Guru,
    Wish to find out why I can compile but cannot run. I encounter the following error: 'Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/jai/JAI
    at saveasone.<init>(saveasone.java:29)
    at saveasone.main(saveasone.java:21)'
    This does not happen on one PC but happened on another PC.
    The one can compile is XP, the other which cannot compile is Win2k Professional. Is there any other possible cause ?
    Please advise.

    The problem probably lies in the Classpath. I think you are using different environments for compiling and running. If you are using an IDE for developing your code, you might have set the classpath correctly there but not in the executing environment. As about the OS's you mentioned, I think the problem is still with your Environment Settings than OS settings.

  • Where are the .java files compiled from .jsp files stored?

              hi,
              I'm new to weblogic server. When I use Tomcat as the jsp server, it compiles .jsp
              files to .java files and then .class files. So when an error reported I can track
              it in the .java file.
              But what should I do with weblogic? It only saves the .class files in the work
              dir. Or is there a better way to trace errors in jsp files?
              Thanks!
              

    This should give you the information you need to set the keepgenerated flag:
              http://e-docs.bea.com/wls/docs60/jsp/admin.html#53346
              Also, the .java files will be right next to the .class files with are under
              a tmp directory in the /WEB-INF directory under the WEB-INF if it is an open
              directory or in the
              config/mydomain/applications/.wl_temp_do_note_delete/WEB-INF directory if it
              is .war file.
              Sam
              "Raymond" <[email protected]> wrote in message
              news:3b931619$[email protected]..
              >
              > Thanks, but can you tell me more about it? where to set this flag? I'm
              using WLS
              > 6.0sp1.
              >
              > "Sam Pullara" <[email protected]> wrote:
              > >You can turn on the keepgenerated flag if you want to keep the .java
              > >files.
              > >How you do this depends on what version you are using.
              > >
              > >Sam
              > >
              

  • RC-50004: Fatal: Error occurred in ApplyDatabase:  Control file creation failed  Cannot execute configure of database using RapidClone

    dear associates,
    linux version: red hat enterprise  linux 4.0.
    EBS version: 12.1.1
    RC-50004: Fatal: Error occurred in ApplyDatabase:
    Control file creation failed
    Cannot execute configure of database using RapidClone
    RW-50010: Error: - script has returned an error:   1
    RW-50004: Error code received when running external process.  Check log file for details.
    Running Database Install Driver for VIS instance

    dear associates,
    can u please assist me how can over come this error or problem.
    linux version: red hat enterprise  linux 4.0.
    EBS version: 12.1.1
    RC-50004: Fatal: Error occurred in ApplyDatabase:
    Control file creation failed
    Cannot execute configure of database using RapidClone
    RW-50010: Error: - script has returned an error:   1
    RW-50004: Error code received when running external process.  Check log file for details.
    Running Database Install Driver for VIS instance

  • Java files work but jar files do not

    Hello everyone!
    My java files run normally and I get a response that I expect (which is successful). Imagine my surprise when I collected them in a Jar and the very same files inside the jar no longer work! I get a response (still generated by my java program) from successful, it turns to Query Expire.
    My problem is, when executed as normal java programs, the expected result is produced. However, when the jars are executed, the result is expired. What is wrong? The classes and the ones in the jar are the same. Is there something different with the mechanism of Jars that make it erroneous?
    Many thanks in advance. I have been working with this for a week with no progress! =(

    Hi!
    Thanks for your reply. Here's what's happening so far:
    I created my java files using Eclipse and using the Export option, I exported them as a JAR.
    When I run my application on Eclipse with the Java files in tow, the output I expect is Done sending: wait for responses now
    Received response from billing api- A: null(0), C: 13, E: Account already registered
    Register: Failed: 1 Failure(s)Now, on to the JAR file.
    I executed the JAR file using the command java -jar <jar name.jar>
    Here's the response:
    Done sending: wait for responses now
    Received response from billing api- A: null(0), C: -1, E: Query expire w/o response
    Register: Failed: 1 Failure(s)My program communicates with a database and this generates the reply that should be received by my program. My ordinary Java file gets the expected output, but the JAR does not.
    Is it possible that the JAR file somehow slows down the transaction? The reply sent by the database isn't received by the JAR -- somehow, the message gets lost.

  • I cannot open AirPortDevices Unix Executable file it says  cannot execute binary file

    i cannot open AirPortDevices Unix Executable file. when i try it says cannot execute binary file

    If you are wiling to share one of these files via Dropbox, I have a few old Macs floating around that I can use to figure out what files these are, if they are not corrupted during the copying process.
    Have you tried OpenOffice or LibreOffice?
    If you can see the dates on these files, you can also try looking at http://en.wikipedia.org/wiki/Comparison_of_word_processors to see what could have been used.
    Do you recall the source machine from where these came? You have mentioned Classic II and SE 30.

  • Can compile, but cant execute

    Hi, I can compile my program but I can't run it. Any help? This is the error:
    Exception in thread "main" java.lang.NoClassDefFoundError: Spaceship
    Caused by: java.lang.ClassNotFoundException: Spaceship
    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)
    Press any key to continue . . .
    Here is my classpath value: C:\Program Files\Java\jdk1.6.0_07\lib;C:\apache-tomcat-5.5.26\common\lib\jsp-api.jar;C:\apache-tomcat-5.5.26\common\lib\servlet-api.jar;C:\Program Files\Java\jdk1.6.0_07\jre\bin;C:\Program Files\Java\jdk1.6.0_07\jre\lib;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Program Files\Java\jre1.6.0_07\bin;C:\Program Files\Java\jre1.6.0_07\lib
    Here's my path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.6.0_01\bin;C:\apache-tomcat-5.5.26\common\lib;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Program Files\Java\jdk1.6.0_07\bin
    and my JAVA_HOME: C:\Program Files\Java\jdk1.6.0_07

    [Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath]
    [How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]
    [Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]
    [Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]
    [Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • How to make the java files compile for a project created outside of Eclipse

    Hi^^,
    I have created a project outside of Eclipse. It has the following folders
    1. config
    2. source
    3. WEB-INF
    I want to execute the project on remote server. Will it compile automatically creating a new folder for .class files corresponding to the source folder or do i need to include a build.xml to enable the project to create a new folder for .class files. Also pls tell me how do I write this build.xml
    Please advise.

    Hi^^,
    Actually I have created a project without using eclipse.
    My source files are inside WEB-INF/source
    Now I want to compile the files using build.xml so that I can create class files. I am using the following build.xml
    <project name="jsp" default="all" basedir="./">
      <property environment="env"/>
      <property file="ArmorJSP.properties"/>
      <!-- set global properties for this build -->
      <property name="source" value="."/>
      <target name="all" depends="copy, jspc, testservlet"/>
      <!-- Creates jsp_servlet directory under WEB-INF\classes of the Examples Web
        APP and places the compiled jsp classes into it -->
      <target name="jspc">
        <!-- Run ejbc to create the deployable jar file -->
        <java classname="weblogic.jspc" fork="yes">
          <arg line="-webapp ${APPLICATION_HOME} -compileAll -d ${APPLICATION_WEB_CLASSES} ${source}/*.jsp"/>
          <classpath>
            <pathelement path="${WL_HOME}/lib/weblogic_sp.jar;${WL_HOME}/lib/weblogic.jar;${ARMOR_HOME}/ARMORSecurity.jar;${ARMOR_HOME}/ARMORUtil.jar"/>
          </classpath>
        </java>
      </target>
      <!-- Creates jsp_servlet directory under WEB-INF\classes of the Examples Web
        APP and places the compiled Servlets classes into it -->
      <target name="testservlet">
        <!-- Run ejbc to create the deployable jar file -->
        <javac destdir="${APPLICATION_WEB_CLASSES}" srcdir="${source}" includes="*.java">
          <classpath>
            <pathelement path="${WL_HOME}/lib/weblogic_sp.jar;${WL_HOME}/lib/weblogic.jar;${ARMOR_HOME}/ARMORSecurity.jar;${ARMOR_HOME}/ARMORUtil.jar"/>
          </classpath>
        </javac>
      </target>
      <target name="copy">
        <copy todir="${APPLICATION_HOME}">
          <fileset dir="${source}">
            <include name="*.jsp"/>
          </fileset>
        </copy>
      </target>
    </project>I do not know how to compile the project using this build.xml
    The motive of doing all this is to understand how is Eclipse doing the build project step. I simply cannot find any build.xml inside any of my projects created in Eclipse however when right click on the project and choose build project, it compiles excellently. ???
    Edited by: pksingh79 on Nov 24, 2008 1:19 PM

  • JSP precompilation and my .java files compilation issues /  building WAR file using ANT

    Hello.
    I am new to working with WAR files and the whole process of it. A little
    background on what we are using. We are using, WLS 6.1 SP3. I am using the
    ant.bat that is supplied in the bin directory of the WLS install.
    I am trying to work with ANT and getting it to build the file. I am making
    progress, but at a point where I am having trouble getting my java code
    files to compile using ant. I am having one issue and looking to do one
    other item.
    1) I would like to precompile the JSPs if possible prior to putting into the
    WAR file. Not sure if this is done or not, but there was a utility when I
    was working with ibm's app server that gave us the ability to do a batch
    complile. Was thinking that maybe a similair concept is possibly here.
    2) Having issue getting ant to compile code properly. In the compile
    section of the build.xml file for ant, I tell it where the source files are,
    and the destionation folder for the compiled class files. I then try to set
    the classpath so that it finds the .jar files that are necessary for my
    source files to complile. But, it won't find them. And not sure how come.
    I may be going about this all wrong, but dont know. Here is the compile
    section of the build.xml I am using:
    <target name="compile" depends="prepare">
    <javac srcdir="classes" destdir="${deploy.home}/WEB-INF/classes"
    classpath="$(lib.home)"
    debug="on" optimize="on" deprecation="off"/>
    </target>
    One note, I've tried many different items in the classpath line, which
    don't work. if I do *.jar it fails at complie time, invalid argument. As
    well as if I use *.* and so on. if I list the explicit file names, it still
    doesn't seem to find them.
    I was wondering if anyone could help, if you need anymore information let me
    know, I can send the entire build.xml if necessary. I may be missing
    items, seeing that this is my first try at using ANT.
    Any help is appreciated and thanks in advance. Hopefully not sounding too
    off the wall. Hopefully get some clarification and understanding.
    Thank you.
    Kevin.

    Kevin Price wrote:
    Hello.
    I am new to working with WAR files and the whole process of it. A little
    background on what we are using. We are using, WLS 6.1 SP3. I am using the
    ant.bat that is supplied in the bin directory of the WLS install.
    I am trying to work with ANT and getting it to build the file. I am making
    progress, but at a point where I am having trouble getting my java code
    files to compile using ant. I am having one issue and looking to do one
    other item.
    1) I would like to precompile the JSPs if possible prior to putting into the
    WAR file. Not sure if this is done or not, but there was a utility when I
    was working with ibm's app server that gave us the ability to do a batch
    complile. Was thinking that maybe a similair concept is possibly here.you can use weblogic.jspc
    http://e-docs.bea.com/wls/docs70/jsp/reference.html#57794
    or just set the precompile flag in weblogic.xml
    You can configure WebLogic Server to precompile your JSPs when a Web
    Application is deployed or re-deployed or when WebLogic Server starts up
    by setting the precompile parameter to true in the <jsp-descriptor>
    element of the weblogic.xml deployment descriptor.
    >
    2) Having issue getting ant to compile code properly. In the compile
    section of the build.xml file for ant, I tell it where the source files are,
    and the destionation folder for the compiled class files. I then try to set
    the classpath so that it finds the .jar files that are necessary for my
    source files to complile. But, it won't find them. And not sure how come.
    I may be going about this all wrong, but dont know. Here is the compile
    section of the build.xml I am using:
    <target name="compile" depends="prepare">
    <javac srcdir="classes" destdir="${deploy.home}/WEB-INF/classes"
    classpath="$(lib.home)"
    debug="on" optimize="on" deprecation="off"/>
    </target>
    maybe because you are not using curly braces there on lib.home??
    if you do it the way above, you would have to list all your jars
    classpath="$(lib.home)\lib1.jar:$(lib.home)\lib2.jar"
    or you can nest
    <javac srcdir="classes" destdir="${deploy.home}/WEB-INF/classes"
    debug="on" optimize="on" deprecation="off">
         <classpath>
              <fileset dir="${lib.home}" includes="*.jar" />
         </classpath>
    </javac>
    One note, I've tried many different items in the classpath line, which
    don't work. if I do *.jar it fails at complie time, invalid argument. As
    well as if I use *.* and so on. if I list the explicit file names, it still
    doesn't seem to find them.
    I was wondering if anyone could help, if you need anymore information let me
    know, I can send the entire build.xml if necessary. I may be missing
    items, seeing that this is my first try at using ANT.
    Any help is appreciated and thanks in advance. Hopefully not sounding too
    off the wall. Hopefully get some clarification and understanding.
    Thank you.
    Kevin.

  • CAN COMPILE BUT CANNOT RUN PROGRAM

    I am finally able to compile my program, I have the extensions .class, when I try to run the program I get an error message "main"java.lang.noclassdef
    after message appears after I type java Saluton or whatever program I am trying to run.
    Any suggestions, someone justed I use textpad, but I don't think this has anything to do with not being able to run programs, I am using windows 98 second edition.

    This is a CLASSPATH problem.
    For example, if your .class file is in the directory C:\javaclasses then you would set the CLASSPATH environment variable to that using:
    set CLASSPATH=C:\javaclasses
    Add this to your autoexec.bat and reboot so you don't have to type this every time you open a DOS prompt.
    You may want to add the current directory, ., to the list of directories (use ; to separate directories).
    set CLASSPATH=.;C:\javaclasses
    If your class is part of a package, you have to use the directory that is the parent of the packages' directories.

  • I have set up a file share but cannot login with my account

    Hi everyone. I set up a file share using the settings in OS 10.5, however when I go to login on Windows Vista using my specially created read only account (called: remote). I cannot get it.
    I can only get in using these settings:
    user name = xxx.xxx.x.xxx\myaccount
    password = blah blah blah.
    Yet when I apply the same settings changing 'myaccount' to 'remote', I cannot get in.
    I'm not sure where I am going wrong, any help would be much appreciated. Thanks!

    No need to apologise, I'm the idiot who can't setup a home network. Although I'm sure Vista is at least to blame somehow.
    I have sharing turned on and it says "Windows users can access your computer at smb://192.168.x.xxx."
    If I click "options" it has a box which has an "on" tick box and my name. I have ticked it. When I ticked it, it asked for my admin password which I supplied.
    On the firewall front I have allow all incoming connections.
    I am trying to login to 'remote' whilst my Mac is still logged in as me, 'nathan' I have successfully logged in to the mac on the same settings using account: 'nathan' on Vista whilst still in 'nathan' on the mac.
    I am trying to connect going into network on vista and selecting my mac, correct.
    The connect works with 'nathan' if I go:
    192.168.x.xxx\nathan
    password
    but for some reason the 'remote' user I have set up wont work on vista using the same format.
    Thanks.

  • File compiles but later i get NoClassDefFoundError

    I wrote the following (shortened) Java-Servlet. I put j2ee.jar, xalan.jar, xalanservlet.jar and xml-apis.jar to the classpath and it compiles without an Error.
    When I now want to start the Servlet on a Domino Server or Tomcat, then
    I get the following Error Message:
    HTTP JVM: java.lang.NoClassDefFoundError: javax/xml/transform/TransformerFactory: javax/xml/transform/TransformerFactory
    I have done everything which I could imagine to get the servlet run. I changed the Servers classpath a lot of times. I use the
    Java(TM) 2 SDK, Enterprise Edition Version: 1.3.1 FCS Release Date: January 2002.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.net.URL;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.Source;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.stream.StreamResult;
    public class SimpleXSLTServlet extends HttpServlet {
    public void doGet (HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException, java.net.MalformedURLException
    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();
    try
    TransformerFactory tFactory = TransformerFactory.newInstance();
    catch (Exception e)
    out.close();
    }

    I wrote the following (shortened) Java-Servlet. I put
    j2ee.jar, xalan.jar, xalanservlet.jar and xml-apis.jar
    to the classpath and it compiles without an Error.
    When I now want to start the Servlet on a Domino
    Server or Tomcat, then Try copying xalan.jar in the common/lib folder for Tomcat
    All files in that folder get added to the system classpath
    I hope that helps.
    Thanks,
    Bhakti
    I get the following Error Message:
    HTTP JVM: java.lang.NoClassDefFoundError:
    javax/xml/transform/TransformerFactory:
    javax/xml/transform/TransformerFactory
    I have done everything which I could imagine to get
    the servlet run. I changed the Servers classpath a lot
    of times. I use the
    Java(TM) 2 SDK, Enterprise Edition Version: 1.3.1 FCS
    Release Date: January 2002.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.net.URL;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.Source;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.stream.StreamResult;
    public class SimpleXSLTServlet extends HttpServlet {
    public void doGet (HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException,
    on, java.net.MalformedURLException
    response.setContentType("text/html;
    ml; charset=UTF-8");
    PrintWriter out = response.getWriter();
    try
    TransformerFactory tFactory =
    ory = TransformerFactory.newInstance();
    catch (Exception e)
    out.close();

  • Forte crashes Win98 when java file compiled

    Have just installed Forte 2.0 in my Win 98, 450 MH P4, 320 MB RAM. Have been using MS Dos command window to compile and run. Can use Forte to edit and save changes to existing programs but when compiled system crashes. PATH point to JAVAC.exe directory. Have set up Project and mounted directory java programs reside in. Need suggestions? Reinstall Forte? Uninstall first? Other? Appreciate e-mail answer as well as forum answer as I am not familar with forum.

    Try uninstalling and reinstalling Forte. Check you have the latest stable release of the JDK and Forte. If all else fails, forget forte, and try another free IDE, to see if you get any similar problems (unlikely).
    Be aware that Forte is not G*d's gift to programmers (IMHO) - think of it more as a curse. You could try JBuilder4 Professional if you are prepared to spend some money. Although not free, the professional version is streets ahead of Forte.

  • Weblogic restart when java files compiled

    when ever i compile java filesi need to restart my weblogic server to effect the compiled classfiles.
    to avoid this what i need to do?
    Do we need to change any properties in xml files or in weblogic administrator

    Make a shortcut to http://dev2dev.bea.com/index.jsp (dev2dev) and http://forums.bea.com/cgi-bin/dnewsweb (Weblogic forums)

Maybe you are looking for