Results 1 to 7 of 7
  1. #1
    Christa912 is offline Member
    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0

    Default 'javac' not recognized as an internal or external command and package does not exist

    So I'm getting the "javac/java not recognized..." error at certain times. I have ClassPath set to c:\Program Files\Java\jdk1.7.0_25\;. and Path set to c:\Program Files\Java\jdk1.7.0_25\bin. I can run a program that I made the other day with no errors. I just open the cmd prompt up in the directory with all the files and it's fine.

    However, I'm trying to compile a program I wrote and it's either giving the first error or the package does not exist error. The professor wants us to use a previously created .jar file for the package. I have an import statement at the top of my file(which is what she said to do). However, it says the package doesn't exist.
    I've tried to compile using javac filename.java(gives package error) and javac -cp C:\package.jar filename.java(gives javac error).Neither work. I'm lost.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: 'javac' not recognized as an internal or external command and package does not ex

    What package is your java file in? Is it in a matching directory? From what directory are you trying to compile? Why do you have a jar in your command? What is the exact text of your command prompt from start to finish (not a screenshot)?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Christa912 is offline Member
    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0

    Default Re: 'javac' not recognized as an internal or external command and package does not ex

    The package is in the jar file, we're not supposed to extract the files from the jar file to use it.Theyre all in the same folder.My command prompt is open in that folder. Now it compiles and says error: could not find or load main class 'javafilename'

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,732
    Blog Entries
    7
    Rep Power
    21

    Default Re: 'javac' not recognized as an internal or external command and package does not ex

    As I understood from your first post, the class is named 'filename', not 'javafilename' (both are bad names, btw).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: 'javac' not recognized as an internal or external command and package does not ex

    I guess this is cause by the way you set the classpath. When you try to run a Java class you can use the -cp option in the command prompt telling where to look for your class. You can use the (.) dot character to point to your current working directory. For example:

    java -cp .;somefilename.jar classfilename

  6. #6
    Christa912 is offline Member
    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0

    Default Re: 'javac' not recognized as an internal or external command and package does not ex

    JosAh: Neither are the file name, I just put a generic name so no one would ask about the program. The actual file name is equations.java and the jar matrix.jar. I'm new to Java, not programming.

    Wsaryada: That was the problem exactly. Just needed the .;
    Thanks!

  7. #7
    dave_13 is offline Member
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Default Re: 'javac' not recognized as an internal or external command and package does not ex

    The problem will be ignored simplly reinstall jdk and set path again

Similar Threads

  1. Replies: 25
    Last Post: 06-23-2012, 12:30 PM
  2. Replies: 12
    Last Post: 01-28-2012, 06:24 PM
  3. Replies: 1
    Last Post: 10-17-2011, 12:15 AM
  4. Replies: 28
    Last Post: 10-26-2010, 05:39 AM
  5. 'javac' is not recognized as an internal or external command
    By sam_1032002@btopenworld.c in forum New To Java
    Replies: 3
    Last Post: 10-18-2008, 03:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •