Unable to use javac or jar commands

Hi all,
I've been using my IDE to compile and run my programs. However, when I want to use -javac or -jar commands in my command prompt, it doesnt work.
The error is :
'javac' is not recognised as an internal or external command,
operable program or batch file
Same goes for jar
-java works for me. Why is that so? I hope anyone can give me solution.
Note : I'm on windows vista
Another question :
I've been using JMF (Java Media Framework) to develop a simple audio player. However it can be run on my pc. What happens if I try to run the program at another pc, will it still work? The other pc will not have JMF installed, but will have JRE to run java apps. If it cannot be run on the other pc, is there any solution?
Thank you for your kind assistance.
Edited by: TrAnScEnD3nT on Sep 30, 2007 10:18 PM
Reason : Sorry I have mixed up java and javac, I've corrected it.

Mainta? That's my favourite!This time...
In very general terms the PATH is a system variable that is maintained and used by your operating system or shell (not Java) to locate executable files. So, for instance, if you type the command:
>writeit will be the PATH that Windows uses to locate the write.exe word processor.
The directory containing the Java tools - java.exe, javaw.exe, jar.exe, appletviewer.exe etc - very commonly goes into the PATH variable.
The classpath is a list of locations that Java uses to locate classes (as you said). It is used by Java and not your operating system. It is commonly (but not always) set each time you use one of the Java tools. There is a -cp switch that lets you do this. For instance a common command to compile a file would be
>javac -cp . HelloWorld.javaThe "-cp ." bit means "the classpath shall be the current directory".
Setting a particular classpath does not, in general, affect the "built in" classes of Java, so you don't have to worry about this. If you search the documentation that came with your distribution you will find the exact rules for "how classes are found": but to begin with the important thing is that any classes you write must be included in the classpath which can be specified as part of the commands to compile or run your code.

Similar Messages

  • Unable 2 use start up key commands after installing TechToolPro (dvd stuck)

    Hi
    After i installed Tech Tool Pro on my new MacBook and restarted, i can not seem to get past a blank screen and endless noise of a spinning DVD,
    I tried Com +V, T, Pram, option but not any start up commands seem to work on this MacBook..
    Please Advise
    Thanks
    Larry

    Come back and tell us or give a link. Glad you got it solved.

  • I am unable to use the about:permissions command from the url bar, when I use this command receive error message "The url is not found and cannot be loaded".

    This was advertised as a new security feature in the nightly build . Is this true has this security been added to Firefox 5.0 or only certain Firefox builds ?

    Yes, that about:permissions page has recently been added to the Nightly builds (7.0a1), but the Aurora builds (6.0a2) have it as well. I don't think that Firefox 5 will get it.
    * [https://bugzilla.mozilla.org/show_bug.cgi?id=573176 Bug 573176] - Implement Site-Specific Privacy Preferences
    * http://www.mozilla.com/en-US/firefox/channel/

  • Using javac and XP

    Hello,
    I am using Windows XP Home Edition and j2sdk1.4.1_01.
    I am getting the following error message upon trying to use javac from the command prompt:
    'javac' is not recognized as an internal or external command,
    operable program or batch file.
    Below is my output upon trying to use javac. I have also provided my current path. Also, as you can see javac.exe is present in the bin directory.
    How do I enable javac from any directory? The instruction Sun provides doesn't seem to work for XP!
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings>path
    PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\j2sdk1.4.1_01\bin
    C:\Documents and Settings\>javac
    'javac' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Documents and Settings\>java
    Usage: java [-options] class [args...]
    (to execute a class)
    or java -jar [-options] jarfile [args...]
    (to execute a jar file)
    where options include:
    -cp -classpath <directories and zip/jar files separated by ;>
    set search path for application classes and resources
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -showversion print product version and continue
    -? -help print this help message
    -X print help on non-standard options
    Here is my <C:\j2sdk1.4.1_01\bin> directory below. As you can see javac.exe is present in the bin directory:
    C:\Documents and Settings>cd ../j2sdk1.4.1_01\bin
    C:\j2sdk1.4.1_01\bin>dir
    Volume in drive C is IBM_PRELOAD
    Volume Serial Number is 6C67-7C74
    Directory of C:\j2sdk1.4.1_01\bin
    01/16/2003 03:21 PM <DIR> .
    01/16/2003 03:21 PM <DIR> ..
    09/30/2002 02:08 AM 28,794 appletviewer.exe
    09/30/2002 02:08 AM 28,792 extcheck.exe
    09/30/2002 02:08 AM 16,384 HtmlConverter.exe
    09/30/2002 02:08 AM 28,794 idlj.exe
    09/30/2002 02:08 AM 28,775 jar.exe
    09/30/2002 02:08 AM 28,796 jarsigner.exe
    01/16/2003 03:21 PM <DIR> java
    09/30/2002 02:08 AM 24,672 java.exe
    09/30/2002 02:08 AM 28,789 javac.exe
    09/30/2002 02:08 AM 28,795 javadoc.exe
    09/30/2002 02:08 AM 28,789 javah.exe
    09/30/2002 02:08 AM 28,785 javap.exe
    09/30/2002 02:08 AM 24,674 javaw.exe
    09/30/2002 02:08 AM 28,798 jdb.exe
    09/30/2002 02:08 AM 28,792 keytool.exe
    09/30/2002 02:08 AM 28,788 kinit.exe
    09/30/2002 02:08 AM 28,788 klist.exe
    09/30/2002 02:08 AM 28,786 ktab.exe
    09/30/2002 02:08 AM 28,806 native2ascii.exe
    09/30/2002 02:08 AM 28,811 orbd.exe
    09/30/2002 02:08 AM 28,798 policytool.exe
    09/30/2002 02:08 AM 28,780 rmic.exe
    09/30/2002 02:08 AM 28,786 rmid.exe
    09/30/2002 02:08 AM 28,798 rmiregistry.exe
    09/30/2002 02:08 AM 28,797 serialver.exe
    09/30/2002 02:08 AM 28,823 servertool.exe
    09/30/2002 02:08 AM 28,813 tnameserv.exe
    26 File(s) 728,003 bytes
    3 Dir(s) 21,616,312,320 bytes free
    C:\j2sdk1.4.1_01\bin>
    As you can see javac.exe is present in the bin directory. How do I enable javac from any directory? The instruction Sun provides doesn't seem to work for XP!
    Thanks, Harvey

    These 2 tests have different errors, and therefore have different solutions.
    I either get:
    C:\Documents and Settings\SHEILA.IBM-IDIYAYPGDZV>cd
    ../../j2sdk1.4.1_01\bin\java
    c hello.java
    The system cannot find the path specified., The error message indicates that MSDOS can not find ../../j2sdk1.4.1_01\bin\javac. Perhaps this is just a typo in your post, but ../../ won't work in MSDOS, at least on my machine. It has to be ..\..\ but when I try the same command adapted for my system and correct the /, it works. (By 'works' I mean the javac.exe is found.)
    C:\Documents and Settings\Walt>..\..\j2sdk1.4.0\bin\javac
    or
    C:\j2sdk1.4.1_01\bin>javac hello.java
    error: cannot read: hello.java
    1 error
    when everything is C:\j2sdk1.4.1_01\bin.In this case, MSDOS found the javac.exe file and executed it. The error message is from the javac compiler and it means the compiler looked in C:\j2sdk1.4.1_01\bin and could not find a file named hello.java. Use the command "dir" and make sure that the file hello.java exists in this directory - especially make sure that the file is not named hello.java.txt
    Going back over your posts, it appears that you have set your Path correctly, so perhaps the "cannot read:" error was the main problem.

  • Unable to build and run Javapetstore using  Sun SDK from Command Line

    Hi,
    Here is a problem I?ve come across building and running JavaPetstore from Command Line using Ant.
    It shows that Build is successful but there is an error message in very beginning:
    ?Unable to locate tools. jar. Expected to find it in C:\Program Files\Java\jre 1.5.0_11\lib\tools.jar?
    But there is no such a file in jre-1.5.0_11 or previous versions.
    The only place where the file with such name can be found is jdk\lib.
    All attempts to run end up with:
    ? BUILD FAILED.
    C:\<PETSTORE_HOME>\bp-project\command-line-ant-task.xml:77;unable to find javac compiler;com.sun.tools.javac.Main is not on the class path.
    Perhaps JAVA_HOME does not point to JDK."
    Directories C:\Sun\SDK\bin and C:\Sun\SDK\jdk are in the PATH.
    JAVA_HOME as a System variable is set up to C:\Sun\SDK\jdk.
    Building and running other applications like a BluePrints or Samples bring to same result.
    I will post more information if needed.
    Thank you in advance for help.

    If you are using Windows XP:
    1. Right click on my computer
    2. Select Properties from the popup dialog
    3. Click on the "Advanced" tab
    4. Click the button towards the bottom that says "Environment Variables"
    5. In the dialog that pops up, look in both the User variables and the System variables for a variable named CLASSPATH
    6. If its not there, you need to create it. If you want to make it available to all users of your computer, create it as a System variable. If you only want it to be available to the current user, add it as a User variable.
    7. If it is there, or if you just created it, it needs to contain the following values: the current directory (symbolically abbreviated as a period: "."), any class libraries you want to be available to the java compiler (javac) or the java interpreter (java). By default, jre/lib and jre/lib/ext are searched for classes, so you don't need to include anything located in one of these folders on the classpath.

  • How can I encrypt my data links between switch uplink ports ? I'm unable to use "cts Manual" command in C3560X switch.suggest me

    How can I encrypt my data uplinks between switch trunk ports ? I'm unable to use "cts Manual" command in C3560X switch.suggest me as I want to encrypt my switch-to-switch link with Cisco TrustSec.

    Hi 
    Login to switch & go to interface..
    There you can give tags.. (ISL & DONT1Q)
    Command switch-port mode trunk
    Switch-port trunk encapsulation ssl or dot1Q

  • Unable to use place command in photoshop

    I am unable to use the place command in photoshop cs5.5 since upgrading to mavericks. The window pops open briefly then shuts immediately. Photoshop hangs as it is still awaiting the action to complets. The same behavior exists when attempting to add attachments to emails. Any idea what may be causing this? This only began to occur after the upgrade to mavericks.

    If should work.  If I read  this correctly your last driver is a year old.  Visit ATI site and download latest.

  • Using javac command

    I have created desktop gui application and I see several files created. I want to compile from the using the javac command. But I do not know which of the files I should compile first. When I build from the IDE, I get no errors. I tried compiling all of these files separartely using javac command and I got many errors.
    myJavaFileView.java
    myJavaFileApp.java
    myJavaFile.java

    Suppose you want to use these three classes.
    There are two possibilities:
    1. Three separate files called myJavaFile.java,myJavaFileView.java and myJavaFileApp.java. With older Java compilers, it may be necessary to compile the file myJavaFile.java first, with
    javac myJavaFile.java
    so that the class file myJavaFile.class is found when compiling later the file myJavaFileView.java and myJavaFileApp.java. On newer compilers, this should happen automatically when compiling myJavaFileApp.java and myJavaFileView.java.
    2. Put both classes into one file. Note that then only one of these classes may have the public modifier in front of it, as in
    public class myJavaFile
    which then has to agree with the filename (that is, the file must be called myJavaFile.java).

  • Can new folder be added into a war using jar commands?

    Hi All,
    I am working on an installer creation attempt to make some changes on a war at the client side to inject my changes into it. As a result i am in need to modify the war using jar commands and have found some success.
    I user the following command.
    D:\MyWarLab>jar uf webtop.war customThis command helped me in adding my changes inside a folder named 'custom' placed at location 'D:\MyWarLab' into the 'custom' folder inside my 'webtop.war'.
    Now this worked as expected since the 'custom' folder was already present inside the war.
    Now my next step is to inject a new folder named 'customA' inside
    webtop.war ->WEB-INF -> classes -> com -> application. This customA folder would contain the java class files i have created.The customA folder does not already exist at the above mentioned location, hence the need to create it.
    I have not been able to find a jar command to add new folders at desired locations of the war.
    Could you please validate my attempt and suggest a command to fulfil my requirement.

    Now this worked as expected since the 'custom' folder was already present inside the war.No. It worked because 'custom' existed in the file system as a directory with files under it. Whether it was already in the war is irrelevant.
    This customA folder would contain the java class files i have created. The customA folder does not already exist at the above mentioned location, hence the need to create it.If it exists on the disk you can add it to the war with the jar uf command.
    I have not been able to find a jar command to add new folders at desired locations of the war.You've already found it!

  • How to create java archive using jar command

    hello
    what is the syntax for creating java acrchive using jar command line
    jar -c ???????
    urgent plzz

    jar cf myjar.jar classfiles...
    If you have a manifest file you want to add:
    jar cfm myjar.jar manifest.mf classfiles...
    Also check the documentation:
    http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html
    You can find a link to jar there.

  • Running a plain java class in command prompt which uses third party jars

    i have to run a simple java class. its actually a process which is running in the background. Now to run this java file i have created a batch file. my problem is that this java file uses around 100 jar files. when i try to run this java file (actually .class file) it gives me no class defination found error for this java(class) file. What can be the problem. My java home is set....how to solve this problem

    i have to run a simple java class
    my problem is that this java file uses around 100 jar filesThese two statements are contradictory.
    it gives me no class defination found error for this java(class) file. What can be the problemThe class is not on the classpath.
    how to solve this problemEnsure all classes are on the classpath.
    I bet if your searched this forum (or even read the java tutorial) you'd find something .

  • Re: Unable to use Cleanup XHTML Commands

    Just got through purchasing and installing DW CS5.5; and I cannot use the Cleanup XHTML command prompt; as I receive the following error message:
    What am I doing wrong? Sorry but I am a newbie at using this latest version; as we previously used DW Version 7. Thanks for any help.

    > Is a recovery disk from another computer using Win7 Home Premium 64-bit usable?
    Generally speaking yes BUT this second notebook must be 100% identical with same model number (PAxxxx).
    > Or if not, am I left with either ordering recovery media from Toshiba, or wiping the entire HDD and installing another licensed version of Win7?
    Exactly. To be honest better option is to order original Toshiba recovery disc.
    You can order it under https://backupmedia.toshiba.eu/landing.aspx
    For 30 euro you will have original disc that you can use anytime you want. This disc has OS with valid licence, all necessary drivers.
    It is also simplest way to have all properly installed. With 5 mouse clicks and after 2 hours only notebook will have factory settings again.

  • JDev 10.1.3 and JDK1.2.2 use javac problem

    I have an old application that I need to compile in 1.2.2, and have tried the "use javac" checkbox on the project properties compile page. The compiler seems to run, but there is an intential error in the code. I put it there, because the class file didn't seem to get generated. I tried this on command line, and apparently '-source' is an invalid option in 1.2.2.
    E:\jdk1.2.2\bin\javac.exe -J-mx512m -verbose -source 1.2 -target 1.2 -encoding Cp1252 -g -classpath E:\jdk1.2.2\jre\lib\rt.jar;E:\jdk1.2.2\jre\lib\i18n.jar;E:\jdk1.2.2\jre\classes;E:\app\codebase;E:\oracle\jdev1013\j2ee\home\lib\ojsp.jar;E:\oracle\jdev1013\j2ee\home\jsp\lib\taglib\ojsputil.jar;E:\oracle\jdev1013\j2ee\home\oc4j.jar;E:\oracle\jdev1013\j2ee\home\lib\oc4j-internal.jar;E:\oracle\jdev1013\j2ee\home\lib\servlet.jar;E:\oracle\jdev1013\jdev\lib\ojc.jar -sourcepath E:\app\src -d E:\PTC\Windchill\codebase @C:\DOCUME~1\gteft\LOCALS~1\Temp\javac30279.tmp
    [1:53:55 PM] Successful compilation: 0 errors, 0 warnings.
    Has anyone else run into this?
    Any help or thoughts on how to adjust this behavior for 1.2.2's javac would be appreciated.

    Thank you for responding. I am aware of (and frustrated by) issues and limitations due to this application's dependancies on an aging platform, and would upgrade if it were my choice. The dependancy is in the vendor's API, and not in code that I can change.
    As the invalid option was not captured as a message or counted as an error, I thought that perhaps this could be a potential issue for using javac with any version.
    I was hoping to see if there were additional settings controlling the command line options that I couldn't find.
    Thanks,
    Greg

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

  • Why I can't use javac? and why my program doesn't pop up cmd window?

    I have 2 questions here:
    1) I try to compile my HelloWorld.java using command prompt,
    javac HelloWorld.java
    But it won't work; by right it should create a HelloWorld.class. When I go to Configure/Options/JDK Profile, it is already showing JDK version 1.6.0_07. My environment variables show User variables and System variables with C:\Program Files\Java\jdk1.6.0_07\bin. This is where my JDK is stored, but I don't know why I can't use javac. It keep saying
    'javac' is not recognized as an internal or external command, operable program or batch file
    2) Why is it when I run my java script using JCreator, the print out appear in the box below in JCreator and not in command prompt? How can I make it pop up on command prompt window?

    Things tend to move fasterYep... until something goes wrong... then you're completely stuffed, because you have no idea what's actually happening, because the idjit IDE is hiding all the gory details... it doesn't even tell you what it's doing, let alone how it's doing it, or what to do when it fails.
    Another argument for the command line is that it's simple. There are 16 distinct dialogues involved in adding a new jar to a library in jBuilder... There may well be less than 16 characters in the equivalent edition to the equivalent build command line. That's an extreme case, I admit, but it goes to disprove the notion that IDE's are simpler for noobs.
    Also, it's easier to get help on command line usage... because it's all text based you can just copy & paste the problematic command and it's output, and the eggspurts (tm) can do likewise with a response... and there are limited number of command lines out there... and *nix, windows, and mac cover maybe 99.5% of java users... and the eggspurts are likely to know all three (colectively if not as individuals) fairly well, because they deal with them all day every day.
    My belief is that noob's are better off at the command line until such time as they need (not just want to play with) a visual debugger... at which time its time to download netbeans and eclipse, and see which one suits you better... if you have money to splurge I'd also evaluate intelliJ... But avoid jBuilder, 2008 is total carp! The FREE eclipse is (IMHO) "nicer to use", and it has a LOT less bugs.
    Cheers. Keith.

Maybe you are looking for

  • Final cut will not open within certain accounts

    Hi First post and mac experience limited but I have Final Cut Express HD which worked fine on a suite of standalone imacs. I have just rebuilt them onto a mac network with a local install of FCE. When I logon as admin, FCE will open no problem but wh

  • Basic setup for Cisco RV325 router

    I am having problem with the basic setup of RV325 router. Example: STEP 1 Connect a PC to a numbered LAN port on the device. If the PC is configured to  become a DHCP client, an IP address in the 192.168.1.x range is assigned to the  PC.  Which LAN p

  • 11.3 Upgrade - What are c3p0 and hibernate logs?

    The 11.3 upgrade documentation states: "Ensure that the c3p0 and hibernate logs for ZENLoader and ZENServer are disabled prior to the upgrade." I can find no instructions on how to do this. Is there a configuration file somewhere that I need to edit?

  • Broadcom 4321 not working

    I have been assigned to use a new CPU on my work, they use wireless only network and gave me an old Broadcom NIC 03:00.0 Network controller: Broadcom Corporation BCM4321 802.11a/b/g/n (rev 03) I can use any OS that I want (arch) but when I boot the i

  • Canon Vixia HF S10 and FCE4 - Log & Transfer

    Please help. Have been trying for hours and can not find the answer on line, at least one that works. I have a Canon Vixia HF S10 and every time I attempt to "add clip to queue" I receive a red octagon that states "Error: No Data". I am using FCE4, o