9 Replies - 10078 Views - Last Post: 17 August 2010 - 05:06 PM Rate Topic: -----

#1 insanepenguin  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 238
  • Joined: 08-July 10

javac and windows 7

Posted 17 August 2010 - 10:33 AM

Hi I can compile program on Vista no problem but when I try to run javac on a win7 machine I get this:

Quote

C:\Program Files\Java\jdk1.6.0_21>C:\Program Files\Java\jdk1.6.0_21\bin>javac My
JavaApplication.java
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.


Any ideas?

Cheers

Is This A Good Question/Topic? 0
  • +

Replies To: javac and windows 7

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3116
  • View blog
  • Posts: 19,153
  • Joined: 14-September 07

Re: javac and windows 7

Posted 17 August 2010 - 10:35 AM

Did you change to that directory? Spaces in file/directory names dictate the use of quotes around the entire thing.

Are your environmental variables set?
Was This Post Helpful? 0
  • +
  • -

#3 insanepenguin  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 238
  • Joined: 08-July 10

Re: javac and windows 7

Posted 17 August 2010 - 10:51 AM

CLASSPATH is set to

Quote

.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip


I have the 64bit JDK installed so I guess this an incorrect path?
Was This Post Helpful? 0
  • +
  • -

#4 SingingBush  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 31
  • Joined: 07-May 08

Re: javac and windows 7

Posted 17 August 2010 - 11:39 AM

If you have you JAVA_HOME set in you environment variables and %JAVA_HOME%\bin is in your PATH variable, then all you need is: javac filename.java
Was This Post Helpful? 1
  • +
  • -

#5 insanepenguin  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 238
  • Joined: 08-July 10

Re: javac and windows 7

Posted 17 August 2010 - 11:56 AM

path:

Quote

C:\Program Files\Java\jdk1.6.0_21\bin;


I set this to %JAVA_HOME%\bin ?

CLASSPATH:

Quote

.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip


Do I need to change this?

I'm a bit confuddled! lol
Was This Post Helpful? 0
  • +
  • -

#6 guido-granobles  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 171
  • View blog
  • Posts: 617
  • Joined: 02-December 09

Re: javac and windows 7

Posted 17 August 2010 - 01:35 PM

For call directly the java compiler you should write :

C:\"Program Files"\Java\jdk1.6.0_21\bin\javac.

For your JAVA_HOME it would be:

JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21
Was This Post Helpful? 0
  • +
  • -

#7 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: javac and windows 7

Posted 17 August 2010 - 01:46 PM

Whatever the problem is, it has nothing to do with Windows 7. I have a Windows 7 and a Windows XP and both compile fine.
Was This Post Helpful? 0
  • +
  • -

#8 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3116
  • View blog
  • Posts: 19,153
  • Joined: 14-September 07

Re: javac and windows 7

Posted 17 August 2010 - 01:57 PM

View Postguidojavier, on 17 August 2010 - 01:35 PM, said:

For call directly the java compiler you should write :

C:\"Program Files"\Java\jdk1.6.0_21\bin\javac.


I would argue that "C:\Program Files\Java\jdk1.6.0_21\bin\javac" is cleaner/better practice.
Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8343
  • View blog
  • Posts: 31,890
  • Joined: 06-March 08

Re: javac and windows 7

Posted 17 August 2010 - 04:14 PM

Your 1.6 is under /Program Files or /Program Files (x86)
your %PATH% should be updated accordingly
Was This Post Helpful? 0
  • +
  • -

#10 SingingBush  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 31
  • Joined: 07-May 08

Re: javac and windows 7

Posted 17 August 2010 - 05:06 PM

In your Control Panel go to System > Advanced system settings > Environment variables.

If you have not already got a JAVA_HOME variable you will need to add one. If you JDK is installed to "C:\Program Files\Java\jdk1.6.0_21" then that will be the value for JAVA_HOME. In your existing PATH variable you will need to make sure that the path to the JDK bin folder is there "C:\Program Files\Java\jdk1.6.0_21\bin". As the java home variable has been set you can use %JAVA_HOME%\bin, or "C:\Program Files\Java\jdk1.6.0_21\bin". It's up to you. (remember a semicolon is needed between entries to your PATH variable).

Once this is done test it on command line:
echo %JAVA_HOME% - should display path to your JDK
echo %PATH% - will show all you paths, so make sure path to JDK bin folder is there.

java -version - should now be able to be done from any directory and give correct version for your JDK.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1