microsoft / vscode-java-debug

Java Debugger for Visual Studio Code.
Other
525 stars 334 forks source link

Urgent please - JavaFx Project runs in a new temporary location which leads to CSS problem. #897

Open ksh-r opened 3 years ago

ksh-r commented 3 years ago

I am running a JavaFX application. Does VSC before running, build a temporary environment/directory and then runs the code from that. I have a stylesheet which uses '@fontface'. The font's .ttf file is present inside the project directory itself. When I run the main java file, it gives a warning 'Could not load @fontface. The following command is executed when I click on Run Project (I have a project.json file in .vscode)

keshar@Keshars-MacBook-Air FTP-Project %  cd /Users/keshar/OneDrive/Documents/s5_cn/CN_Project/FTP-Project ; /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:53519 --module-path /Library/Java/Extensions/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml -Dfile.encoding=UTF-8 @/var/folders/1z/b0nhrzfn3kz1h3swpnj7qglm0000gn/T/cp_2an02mwlmzj91bhxxwucqhc2e.argfile app.App 

The ending of the above command is given below and my project is not located in this directory. -Dfile.encoding=UTF-8 @/var/folders/1z/b0nhrzfn3kz1h3swpnj7qglm0000gn/T/cp_2an02mwlmzj91bhxxwucqhc2e.argfile app.App

The warning that it gives is: Oct 23, 2020 7:02:23 PM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged INFO: Could not load @font-face font [file:/Users/keshar/Library/Application%20Support/Code/User/workspaceStorage/13500534c7f134388e0c57a339b26045/redhat.java/jdt_ws/FTP-Project_ad912ab4/bin/app/fonts/SimploCustom.ttf]

The project itself is not located in Library/Application Support/Code so why is it searching the .ttf file in the above path? How can I disable the creation of the temporary directory ?

Environment
Steps To Reproduce
  1. [step 1] Make a JavaFX project.
  2. [step 2] Add a stylesheet and import a font using '@fontface'

[Please attach a sample project reproducing the error] Please attach logs

Current Result
Expected Result
Additional Informations
testforstephen commented 3 years ago

The ending of the above command is given below and my project is not located in this directory. -Dfile.encoding=UTF-8 @/var/folders/1z/b0nhrzfn3kz1h3swpnj7qglm0000gn/T/cp_2an02mwlmzj91bhxxwucqhc2e.argfile app.App

The temp file @/var/folders/1z/b0nhrzfn3kz1h3swpnj7qglm0000gn/T/cp_2an02mwlmzj91bhxxwucqhc2e.argfile is used to save the classpath arguments so as to shorten the command line length, which is supposed not to affect your program's behavior.

The warning that it gives is: Oct 23, 2020 7:02:23 PM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged INFO: Could not load @font-face font [file:/Users/keshar/Library/Application%20Support/Code/User/workspaceStorage/13500534c7f134388e0c57a339b26045/redhat.java/jdt_ws/FTP-Project_ad912ab4/bin/app/fonts/SimploCustom.ttf]

You're opening a non-buildtool Java folder, and the Java extension will initialize it into a temp invisible project and build the .class output to the temp bin dir FTP-Project_ad912ab4/bin. No plan to change this behavior yet. If you didn't want the temp directory, you need create a maven project for this.

Looks like this error is just because the font file is not compiled to the temp output directory. One workaround is to put the font file to the same source folder as your Java file. The build tool is supposed to compile the non-java resource in the source folder to the output folder.