Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: compile and run both  (Read 2871 times)

0 Members and 1 Guest are viewing this topic.

san_crazy

    Topic Starter


    Intermediate

    compile and run both
    « on: September 27, 2008, 12:38:37 AM »
    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?

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: compile and run both
    « Reply #1 on: September 27, 2008, 03:51:53 AM »
    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.

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein