I have Windows 7, not OS X.
I configured my Sublime Text 2 with that turorial:
Compile and Run Java programs with Sublime Text 2
It works fine with this code:
But if i want to compile & run Code with an import, it doesn't work anymore.
So my Question is how to configure this batch code, that i can compile & run java code which includes imports ?
@ECHO OFF
cd %~dp1
ECHO Compiling %~nx1.......
IF EXIST %~n1.class (
DEL %~n1.class
)
javac %~nx1
IF EXIST %~n1.class (
ECHO -----------OUTPUT-----------
java %~n1
I've been using the following setup for running java in sublime 2, and I just tested the import function and it worked fine:
Make the bat file with the following, and save it anywhere in your PATH. I suggest C:\Program Files\Java\jdk*\bin\ to keep everything together.
@ECHO OFF
cd %~dp1
javac %~nx1
java %~n1
then edit C:\Users\your_user_name\AppData\Roaming\Sublime Text 2\Packages\Java\JavaC.sublime-build, the contents will be
{
"cmd": ["javac", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}
replace "javac" with the name of your bat file (for instance, javacexec.bat) and save it.
Now you should be able to run it using ctrl+b.
This package for sublime text 2 solved my problem.
https://github.com/psychowico/SublimeJavaCompiler
Features:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With