javamavenvisual-studio-codevscode-extensionsmaven-compiler-plugin

How can I copy a JavaFX code that perfectly builds and runs to a remote ssh server in Visual Studio Code?


I tried to copy the java project folder in remote ssh server. Then I opened Visual Studio Code and used SSH FS extension by Kelvin Schoofs to open the remote folder. Then I opened the main .java App file, and then I pressed "Play" button to compile and run java, but it does not work, it says:

$  cd /run/user/1000/gvfs/sftp:host=mynamesite.duckdns.org,port=9022/path/to/project ; /usr/bin/env /usr/lib/jvm/java-11-openjdk/bin/java @/tmp/cp_5b2xgbx2rjiw3h09vd2sbor51.argfile -m com.example/com.example.App 
Error occurred during initialization of boot layer
java.lang.module.FindException: Module com.example not found

But even if I just do ctrl+shift+p and do a brand new JAVAFX project, the interactive project creation fails and says:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate (default-cli) on project vipagepharma: Unable to add module to the current project as it is not of packaging type 'pom' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The terminal process "/usr/bin/bash '-c', 'mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="javafx-archetype-fxml" -DarchetypeGroupId="org.openjfx" -DarchetypeVersion="RELEASE" -DgroupId="com.example" -DartifactId="demo"'" terminated with exit code: 1.

Solution

  • Here are some of my suggestions:

    First, please confirm whether the jdk you installed has JavaFX. Then you can try to import all dependencies using npm and run the project.

    Or You can simplify this whole process by switching to Maven based projects. A maven project has all build and dependency information in a file called pom.xml and will simplify all other dependency issues. The steps are detailed on Getting started with JavaFX 11 with maven.

    Finally, there is a VSCode extension called Ant Target Runner that might help you.

    Hope this helps you.