1.

Solve : compile and run both?

Answer»

hi friends,

I made a batch FILE to compile java programs using javac

here it is
Code: [Select]@ echo off

cd C:\Program Files\Java\jdk1.6.0_02\bin

javac %1

at commond line i type jrun javafile.java

then the target file GET compiled successfully.

now what code snippet should I add to run the class file also using java class LOADER tool, that has been come from compilation?This should HELP you with the mechanics, you may have to provide the details:

Code: [Select]@echo off
javac %1.java
if not errorlevel 1 java %1.class

Quote

at commond line i type jrun javafile.java

Change that to jrun javafile and let the batch file determine the file extensions.

Check your path, if the java install did not add itself to your path, then a suggestion would be to LOGIN to the directory where your source code resides and use a path pointer to java directories. This will keep your source libraries and the java libraries separate.

Code: [Select]@echo off
cd C:\YourSourceDirectory
C:\Program Files\Java\jdk1.6.0_02\bin\javac %1.java
if not errorlevel 1 C:\Program Files\Java\jdk1.6.0_02\bin\java %1.class

You will have to test this to make sure java can find all it's components.



Discussion

No Comment Found