Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Programming in Notepad with cmd
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
revangrey




PostPosted: Tue Mar 30, 2010 10:33 pm   Post subject: Programming in Notepad with cmd

I tried back in the summer break to write my code in notepad and compile it using the javac command in command prompt. To no avail.

Now that I have started computer science again I wanted to try coding in notepad++ or notepad (anything really, we use RTP in class)

I get the error 'javac' is not recognized as an internal or external command, operable program or batch file.

I tried the help here: http://java.sun.com/javase/6/webnotes/install/jdk/install-windows.html

here: http://java.sun.com/docs/books/tutorial/getStarted/problems/index.html
here: http://chortle.ccsu.edu/java5/Notes/chap05/ch05_13.html (good site, thanks to whoever gave it to me on this forum Very Happy)
and here: http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html

I am running windows vista 64 bit (I think) on a laptop, but I am quite sure that the problem is me rather than the OS because I could not do any better on XP. (didn't try as hard back then I will admit).
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Tue Mar 30, 2010 10:49 pm   Post subject: RE:Programming in Notepad with cmd

Probably didn't set the Class_Path (it's option 4 and is labeled optional but it's required if you want to easily compile from cmd). Normally you have to type:
C:\Program Files (x86)\Java\jdk1.6.0_18\bin\javac.exe [file your compiling]...
However you can set a variable for Windows to look in a specific folder for executables.

Control Panel > System
Advanced Tab/Option > Environment Variables
Under System Variables, find PATH. Edit it. At the end of it, place a semicolon ( ; ). Then find your install of the JDK, it'll look something like this:

C:\Program Files (x86)\Java\jdk1.6.0_18\bin

Make sure your select the bin folder since that's where javac.exe is.
chrisbrown




PostPosted: Tue Mar 30, 2010 10:53 pm   Post subject: Re: Programming in Notepad with cmd

First, kudos for getting down and dirty; you'll learn much more this way.

From the ccsu site:
Quote:
If you see the following

[...]
The name specified is not recognized as an
internal or external command, operable program or batch file.

then the PATH environment variable has not been set correctly.

How to fix this
In this case, you want to add the directory that javac.exe is located in, something along the lines of C:\Program Files\Java\jdk_something\bin. You may need to use "Program Files (x86)".
revangrey




PostPosted: Tue Mar 30, 2010 11:08 pm   Post subject: Re: Programming in Notepad with cmd

Completely my fault for not being specific enough...

I tried using the java in both the Program files and the Program files (x86) folder, and I didn't have anything called "PATH" to edit in system...

the "C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip" in QT java looked like the closest thing to java there already (also what led me to try (x86))

I also tried C:\Program Files\Java\jdk1.6.0_1\bin

C:\Program Files (x86)\Java\jdk1.6.0_18\bin\javac.exe (this one I made a new variable "PATH" since there was not one already"

I will go over what I have done and try some more combinations, but I dont think I made any mistakes...

Thanks the help though!
Zren




PostPosted: Tue Mar 30, 2010 11:23 pm   Post subject: RE:Programming in Notepad with cmd

Can you find your installation of the JDK in explorer? What folders are in C:\Program Files (x86)\Java\ ?
Tony




PostPosted: Tue Mar 30, 2010 11:53 pm   Post subject: Re: Programming in Notepad with cmd

revangrey @ Tue Mar 30, 2010 11:08 pm wrote:
but I dont think I made any mistakes...

revangrey @ Tue Mar 30, 2010 11:08 pm wrote:
I didn't have anything called "PATH" to edit in system...
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
revangrey




PostPosted: Wed Mar 31, 2010 12:06 am   Post subject: Re: Programming in Notepad with cmd

Posted Image, might have been reduced in size. Click Image to view fullscreen.

I put that path there... I really have no idea what you mean...

I didn't delete one if that is what you are insinutating?

You should probably just spell out for me what it is you are thinking to clarify Smile (I really don't understand...)

and in response to previous :

In the C:\Program Files(x86)\Java\ I have

Posted Image, might have been reduced in size. Click Image to view fullscreen.

and in the C:\Program Files\Java I have

Posted Image, might have been reduced in size. Click Image to view fullscreen.

and javac is in the bin folder of the Program Files, and x86 bin folder.


Also I probably won't have time to try out anything new until later this afternoon (after school), but any advice posted until then is much appreciated!
Zren




PostPosted: Wed Mar 31, 2010 12:17 am   Post subject: Re: Programming in Notepad with cmd

Delete the variable javac, it's of no use. Delete the PATH variable for your account if you made it (the top section, not system). Not entirely sure but the latter could override the system (though it could easily also just add to it).

Path C:\Program Files (x86)\Java\jdk1.6.0_01\bin
In both the Path variables in the screenshot you forgot the red.

If PATH doesn't work, try Path.
Sponsor
Sponsor
Sponsor
sponsor
chrisbrown




PostPosted: Wed Mar 31, 2010 12:20 am   Post subject: RE:Programming in Notepad with cmd

In your PATH value, are you including javac.exe? If so, remove it; PATH should be a directory, not a file.
revangrey




PostPosted: Wed Mar 31, 2010 6:55 pm   Post subject: Re: Programming in Notepad with cmd

I tried path and PATH, both after deleting the javac.exe part and ending at "bin".

...unfortunately this did not work, but something interesting happened to any new cmd windows that I opened

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Most commands that I would use every day "calc", "mspaint", "notepad", and that fancy one up above don't seem to work on any but the first command prompt window...

I think this means that my new path additions prevent cmd accessing it's own commands.

just a theory... (I am quite lost)

Also sorry for being such a hassle Confused
chrisbrown




PostPosted: Wed Mar 31, 2010 7:35 pm   Post subject: RE:Programming in Notepad with cmd

Look at your PATH variable. It should have a list of semicolon-seperated directories.

From the looks of it, a reference to system32 was removed or damaged. Try setting your path to this and see what happens:
code:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Java\jdk1.6.0_01\bin


Just so it's clear, the purpose of setting that is so you don't have to type the full path to javac. Instead of "C:\.....\javac.exe fileName", you can just use "javac fileName".
Tony




PostPosted: Wed Mar 31, 2010 7:58 pm   Post subject: RE:Programming in Notepad with cmd

Looking at your screenshots, just a note: spaces are used to separate arguments.

That is, if you type in
>C:\Program Files\...

Then "C:\Program" is the command, and "Files\..." is the argument.

(This is why programmers don't like spaces and join_words_with_underscores)

To fix that, use quotation marks, or escape characters.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DemonWasp




PostPosted: Thu Apr 01, 2010 12:49 am   Post subject: RE:Programming in Notepad with cmd

Alternately, you can use dir /X to list the "short" name of the file (8.3 format). These never include spaces. On my system, Program Files (x86) is PROGRA~1. Windows will expand this path to the "real" path automagically.
revangrey




PostPosted: Fri Apr 02, 2010 1:22 am   Post subject: Re: RE:Programming in Notepad with cmd

methodoxx @ Wed Mar 31, 2010 7:35 pm wrote:
Look at your PATH variable. It should have a list of semicolon-seperated directories.

From the looks of it, a reference to system32 was removed or damaged.


I guess you were correct because your path worked. Also thank you very much for it!

Posted Image, might have been reduced in size. Click Image to view fullscreen.

The javac command seems to be working, and I can access the java help menu and such; but for some reason it doesn't want to access the file.

I will try something else after some much needed sleep. (about 32 hours)

Thank you everyone for all your help, and I will read it over once I am conscious enough to comprehend it Laughing

For example the dir/x thing, I have no idea what I would use that for Confused (but I am sure it is useful somehow...)

p.s. you guys are amazing; I don't know how else to put it.


EDIT: Just wanted to say I have it working near perfectly now.

To run all I have to do is save f6 then enter and it works (within notepad ++)
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: