spywhere / Javatar

Java Development Plugin for Sublime Text 3
https://javatar.readthedocs.org/
Other
170 stars 20 forks source link

Error when building project in Windows #52

Closed eternalphane closed 9 years ago

eternalphane commented 9 years ago

Everytime I try to build java code the following error appears in a new view:

javac: 无效的标记: 'D:\Projects\[Java]\HelloWorld\src\helloworld\Main.java'
用法: javac <options> <source files>
-help 用于列出可能的选项

Then I try replacing the build executable javac with echo in user setting and find that Javatar use single quote to enclose paths in build command:

javac -sourcepath 'D:\Projects\[Java]\HelloWorld\src' -classpath . -d 'D:\Projects\[Java]\HelloWorld\bin' 'D:\Projects\[Java]\HelloWorld\src\helloworld\Main.java' -Xlint:all

However single quote donnot behave as what double quote do in CMD. It regards 'aaa bbb' as two strings 'aaa and bbb' instead of one. So what should I do to solve this problem?

spywhere commented 9 years ago

Are you using Builds -> Project/Package/Class menu? If not, try use that menu since Javatar use its own build system.

If you're already using the build menu above, try writing your own build command in the build_command key in the settings file.

Javatar always use double quotes when passing to the command line. (Here's in the create_build method where the build command is building up and run)

eternalphane commented 9 years ago

Indeed Javatar use double quotes in release branch, but I'm currently using master branch for there's no encoding key in settings file of the former one. I've tried release branch before but still met some problems and what's worse is that the error log is encoded incorrectly......

eternalphane commented 9 years ago

I remember the error massage is something like XXX "C:\Program Files\Java\jdk1.8.0_60\lib\tools.jar" XXX.

spywhere commented 9 years ago

Ah, you're using the prerelease version.

For quoting, that's expectable but that should not make the different since a new version of Javatar use Python's shlex.quote for quoting the string.

Here on line 181, there is an encoding key for you.

eternalphane commented 9 years ago

image I've just tried in CMD. Python's shlex.quote will automatically enclose string with single quote......

eternalphane commented 9 years ago

And after adding double quotes to the keys in settings file it gets stuck at 0%... image

spywhere commented 9 years ago

Could you try replace generic_shell.py in core/ with the file below?

https://dl.dropboxusercontent.com/u/65468988/Sublime/Javatar/generic_shell.py

And see if it's works this time.

eternalphane commented 9 years ago

image Thanks, but the URL seems to be incorrect...

spywhere commented 9 years ago

Here... both link (above and this link) seem valid to me (I can ensure that I copy and paste it not typing it myself)

https://gist.github.com/spywhere/4834d4a0b8ef174b3de8

eternalphane commented 9 years ago

The second link cannot work either. Probably due to GFW... I'll try again with VPN connected.

eternalphane commented 9 years ago

Unfortunately it shows the same error message, and the build script is still javac -sourcepath 'D:\Projects\[Java]\HelloWorld\src' -classpath . -d 'D:\Projects\[Java]\HelloWorld\bin' 'D:\Projects\[Java]\HelloWorld\src\helloworld\Main.java' -Xlint:all.

spywhere commented 9 years ago

Sure, the build script is not changed but that file just changed how the shell receive the command.

I will look into this issue again which might take a while since I currently working on another project. In the mean time you might want to change the shlex.quote to wrapping double quotes around (if that works for you). Sorry for any inconvenience you might have.

eternalphane commented 9 years ago

Thanks for your advice. I'll try that later.

spywhere commented 9 years ago

I have added the debug message when running the program to Javatar v2.0.0-prebeta. This should returns the run script to the console. If possible, I want you to try running that script in the command prompt yourself (make sure the escape characters has been escaped) so I can ensure that it's the quoting problem not the build system itself.

eternalphane commented 9 years ago

image

eternalphane commented 9 years ago

After modified /core/generic_shell.py, Javatar is now working quite well on my computer.

spywhere commented 9 years ago

The modified core/generic_shell.py is up (in the Javatar v2.0.0-prebeta). This should solve the quote problem now.