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

Author Topic: batch script?  (Read 2387 times)

0 Members and 1 Guest are viewing this topic.

jon80

  • Guest
batch script?
« on: May 12, 2011, 03:33:00 AM »
I have downloaded NotePad++, and, according to the online help (see page at http://npp-community.tuxfamily.org/documentation/notepad-user-manual/commands), it seems possible to run a command that would allow me to execute a scripted file.

Hence, I would like to create a script file that allows me to capture whatever the user (e.g. myself) has loaded from within the application, and, launch it by the Java compiler, for example:

compile_a_java_program.bat
@echo off
javac %1.java
rem where %1 is the name of the file currently being viewed by the user
java %1
rem usually ending with .class, where this is the name of the file that needs to run

I am running WinXP SP3, and, JVM 1.6.0_24.
 
???

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: batch script?
« Reply #1 on: May 12, 2011, 09:18:35 AM »
In the Notepad++ run box, use the ... button and find your batch file. Double clicking it will move full path to the run box; then add $(FULL_CURRENT_PATH) to the run box. The run box should look something like this:

Quote
compile_a_java_program.bat $(FULL_CURRENT_PATH)

If necessary, add path info for your batch file.

You batch file might need a tweak or two:

Code: [Select]
@echo off

javac %1

cd /d %~dp1
java %~n1
pause

I threw in the pause so you can see the result before the window closes. I also added a CD command to navigate to the directory where the class file lives, just in case the directory is not on the classpath variable.

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

-- Albert Einstein