cse-icons, on Dec 9 2004, 08:33 PM, said:
Yeah, I think that is possible...
Just right click on .java file and select open with...
from the list select javac.exe (if it exists) or browse to it and select it.
chek the box.. always open with... and there u r....
double click and it should compile...
I have not tried it yet.. but should def work...
similarly for class files.. associate it with java.exe
If these dont work... i suppose u can write a batch file.. which compiles and runs both...
There is sthg u can do in the registry so that in the context menu u get compile and it would compile with javac.exe
wud try out and let u know..
<{POST_SNAPBACK}>
I've tried this method...
It's normal when the DOS window open and exit. Once the DOS command finishes the window will be closed automatically.
And in fact I don't recommend this method since you won't be able to read the error messages from the compiler, although you will still be able to compile the program.
Also note that you won't be able to run the program just by "associating it with java.exe". Reason? Do you remember after you compiled the program successfully (e.g. javac testprog.java), what's the command you need to type in order to interpret (execute) the program? It's (javac testprog). You can't include the ".class" when executing the program, or you'll get an error message. And when you associate a file with a program, Windows just append the filename to the end of the program. So when you associate that *.class file to java.exe and you run testprog.class, you will get "java testprog.class" - it won't work. Try it on your own.
khmerneed, on Dec 15 2004, 09:55 AM, said:
Hi,
I have tried so many times, but it is not run that way. when i double click on it, it gone to be open the dos then exit.
I wonder if i have another way.
Thanks & Best Regards,
Dorei
<{POST_SNAPBACK}>
Like cse-icons said, create a batch file to handle the task. But the easiest way may be to simply use an IDE to write and compile the program.
** Edit
Create a batch file to do the task:
Save the following code to
runjava.bat under folder
C:\j2sdk1.4.2_04\bin
@echo off[br]title Java Compiler[/br]if "%1" == "" goto Help[br]echo Compiling...[/br]javac %1.java[br]if ERRORLEVEL 1 goto Error[/br]echo Compile successful. Running program...[br]java %1[/br]goto End[br]:Help[/br]echo Compiles and run a java program.[br]echo.[/br]echo RUNJAVA [filename][br]echo.[/br]echo [filename] File name of the java source code (without .java extension)[br]goto End[/br]:Error[br]echo *** Compile failed ***[/br]:End[br]
[/br]What a long post...