Java compileren op notepad++ lukt wel maar niet overal.

Moderators: jkien, Xilvo

Reageer
Berichten: 2.504

Java compileren op notepad++ lukt wel maar niet overal.

Ik heb dit al eens gevraagd maar vind het topic nergens terug.

Nu, om java te compileren en te runnen in Notepad++ is de entry op een bepaald forum best goed:
I've found the way to compile & run Java applications from Notepad++ with just one hotkey.

First of all, go to the directory where you have installed Notepad++ and create a new file called CompileJava.bat

then open it and enter these lines:

Code: Selecteer alles

@echo off

path=%path%;"<path to your BIN directory of JDK>"

@echo on

javac %1

java %2

pause
Save the file and exit.

After that, open Notepad++ and press F5. Fill in the box in the small window that appears with:

Code: Selecteer alles

$(NPP_DIRECTORY)\CompileJava.bat $(FILE_NAME) $(NAME_PART)
Probleem met dit voorbeeld is dat het enkel werkt als je Java bestand(en) in de Notepad++ map staan op je harde schijf.

Veel handiger zou zijn moest je dit kunnen waar dan ook op je harde schijf.

Zelf ken ik niet genoeg van batchcode om te weten hoe dit aan te passen...

Heeft iemand enig idee hoe dit op te lossen?
"Invisible Pink Unicorns are beings of great spiritual power. We know this because they are capable of being invisible and pink at the same time. Like all religions, the Faith of the Invisible Pink Unicorns is based upon both logic and faith. We have faith that they are pink; we logically know that they are invisible because we can't see them."

Gebruikersavatar
Berichten: 6.905

Re: Java compileren op notepad++ lukt wel maar niet overal.

kan je aan dat .bat bestand geen niets toevoegen in de stijl van

cd %3

en dan $(NPP_DIRECTORY)\CompileJava.bat $(FILE_NAME) $(NAME_PART) $(CURRENT_DIRECTORY)

(http://notepad-plus.sourceforge.net/nl/site.htm)
Het vel van de beer kunnen verkopen vraagt moeite tenzij deze dood voor je neervalt. Die kans is echter klein dus moeten we zelf moeite doen.

Berichten: 2.504

Re: Java compileren op notepad++ lukt wel maar niet overal.

jhnbk schreef:kan je aan dat .bat bestand geen niets toevoegen in de stijl van

cd %3

en dan $(NPP_DIRECTORY)\CompileJava.bat $(FILE_NAME) $(NAME_PART) $(CURRENT_DIRECTORY)

(http://notepad-plus.sourceforge.net/nl/site.htm)
heb de cd %3 nog niet toegevoegd, maar

Code: Selecteer alles

$(NPP_DIRECTORY)\CompileJava.bat $(FILE_NAME) $(NAME_PART) $(CURRENT_DIRECTORY)
werkt meteen. Bedankt, ik vind de manier waarop Notepad++ verwijst naar dingen, "$(FILE_NAME)" enzo, best merkwaardig. Heb moeite ermee te werken soms.
"Invisible Pink Unicorns are beings of great spiritual power. We know this because they are capable of being invisible and pink at the same time. Like all religions, the Faith of the Invisible Pink Unicorns is based upon both logic and faith. We have faith that they are pink; we logically know that they are invisible because we can't see them."

Gebruikersavatar
Berichten: 6.905

Re: Java compileren op notepad++ lukt wel maar niet overal.

En wat doet het met %3? Ik vraag mij af hoe het dan zonder werkt :D
Het vel van de beer kunnen verkopen vraagt moeite tenzij deze dood voor je neervalt. Die kans is echter klein dus moeten we zelf moeite doen.

Berichten: 2.504

Re: Java compileren op notepad++ lukt wel maar niet overal.

En wat doet het met %3? Ik vraag mij af hoe het dan zonder werkt :D


Not sure, ik neem aan dat Notepad++ intern wel de spierballen heeft om die directory compleet te vinden en correct te gebruiken.
"Invisible Pink Unicorns are beings of great spiritual power. We know this because they are capable of being invisible and pink at the same time. Like all religions, the Faith of the Invisible Pink Unicorns is based upon both logic and faith. We have faith that they are pink; we logically know that they are invisible because we can't see them."

Gebruikersavatar
Berichten: 6.905

Re: Java compileren op notepad++ lukt wel maar niet overal.

ah nee, dat heeft niets met np++ te maken aangezien np++ die waarden gewoon naar dat batchbestand doorgeeft. Mogelijk wordt het laatste niet gebruikt argument als current path gebruikt.
Het vel van de beer kunnen verkopen vraagt moeite tenzij deze dood voor je neervalt. Die kans is echter klein dus moeten we zelf moeite doen.

Gebruikersavatar
Berichten: 829

Re: Java compileren op notepad++ lukt wel maar niet overal.

Ik denk dat notepad gewoon de homedirectory aanpast wanneer je een document opent, waardoor bij het uitvoeren het path al juist staat. Ofwel werkt het met 2 paths. Ik denk dat hij dus intern de path aanpast, en indien je het batch-bestand laat runnen het gewoon het volledige path van het batch-bestand in de command-line schrijft.

maar ik ben het niet zeker.
"Als je niet leeft zoals je denkt, zul je snel gaan denken zoals je leeft."

--Vladimir Lenin-- (Владимир Ильич Ульянов)

Reageer