I am trying to setup my JavaFX enviroment so I referenced the corresponding Jars. In order to run the code I need to use some VM Arguments
("vmArgs": " --module-path /Users/adrif/Downloads/javafx-sdk-14.0.2.1/lib --add-modules javafx.controls,javafx.fxml")
in the launch.json. I am working in a multi-project folder so every time a make a new one I have to go to the launch.json and add the arguments. How do I set global arguments? I found adding arguments in "launch" at user settings.json (Launch - Global debug launch configuration. Should be used as an alternative to 'launch.json' that is shared across workspaces)
but doesn't work as I expected.
As you can see, I have two JavaFX projects under the package JavaFX.
And every time I run a new project I have to add the vmArg line to each project.
This is the "launch" options but as I said, it doesn't work or there's someting wrong with how I'm trying to do it. So as the title sais, how to I set global arguments?
Edit : I found the "java.jdt.ls.vmargs" option which allows to specify extre VM Arguments. I does not work either.
Solved, turns out it was fixed in newer versions of Vscode and it's pertinent Java Extensions. The workaround that I used was just adding a new set of arguments for every file in the project.
"vmArgs" was JVM related, "java.jdt.ls.vmargs" was java language server related, the language server was contained in the "Language Support for Java(TM) by Red Hat" extension, so it will not work.
The "launch" configuration in settings.json I tried in local and does not work too.
VSCode has not provided this feature for the present, You need to configure the "vmArgs" for each project. This is because the launch.json file contains different language debugging settings, and lots of configuration was exclusive to some language.
Related
While developing some plugins based on Eclipse, I need to add some default VM arguments when user right click-> "run as" -> "java application" or "spring boot app", is there any open api I can call or any extension point?
Just like the snapshot below, the argument "-Daaa=bbb" is added by default.
Any help is appreciated.
You need to write your own plugin and need to replicate/extend Java launch configuration
(of type Java application) from JDT and add -vm argument programmatically.
But there is one more easy way: Try LcDsl.
LcDsl provides a way of defining Eclipse launch configurations in a textual way. The file extension used is '.lc' It provides some obvious and some non-obvious advantages over the Eclipse launch configuration solution.
For more info look here and check demo videos. Also there was a discussion going on to include this plugin in JDT itself, see this bug entry.
A typical Java launch configuration looks like this:
java configuration LcJavaMain {
project com.wamas.test;
main-class com.wamas.test.JavaMain;
memory min=64m max=256m;
vm-argument '-Dmy.arg=value';
argument 'cmdArg';
}
I am trying to figure out how to add the command line arguments
-XX:CompileCommand=print,javax/swing/text/GlyphView,getBreakSpot
to eclipse in order to fix a JIT problem documented in
http://kingsfleet.blogspot.com.br/2014/11/but-thats-impossible-or-finding-out.html
but i am unsure how to add this.
If this is part of building as indicated in your question's title then: You can't. That is an argument specific to Oracle's javac. Eclipse's Java Builder uses Eclipse's compiler. If you use ant or any other external tool, to run Oracle's javac then you can add arguments for it.
If this is a runtime option (since you mention the JIT), then you can add any arguments for the JRE in the Run Configuration dialog.
I just skimmed the article you referenced. It is an argument to 'java', not 'javac' and has nothing to do with building. Enter it in the Arguments tab of the Run Configuration dialog.
It seems like you need "boot time parameters" for your Eclipse, well before the projects are loaded. If I have understood the question correctly, have you tried using eclipse.ini? Here are a few lines from my ini file where I change some parameters.
--launcher.appendVmargs$
-vmargs$
-Dosgi.requiredJavaVersion=1.6$
-XX:MaxPermSize=256m$
-Xms40m$
-Xmx1524m$
-Dgrails.console.enable.interactive=false$
-Dgrails.console.enable.terminal=false$
-Djline.terminal=jline.UnsupportedTerminal$
-Dgrails.console.class=grails.build.logging.GrailsEclipseConsole$
If I havent' understood your question, please clarify, if not, hope this helps.
I want to build a maven integrated project with a given java home property. At exactly i want to write a code in java that sets the java home property for an InvocationRequest object. The main goal is to build a project with the runtime given(by an algorithm) java home. So i would call getInvoker().execute(request); to execute maven goals where request is an InvocationRequest object.
I tried to set the request java.home property with properties.setProperty(Goals.JAVA_HOME, javaHomePath); and call the method executeGoals(pom, new String[] { Goals.INSTALL, Goals.CLEAN }, properties); . This executeGoals(...) method contains getInvoker().execute(request) call and the request object definition too.
Output is: Missing: 1) com.sun:tools:jar:1.5.0 #Solved
EDIT: solved the output problem, but a new one appeared:
class file has wrong version 50.0, should be 49.0. Maybe i changed the jre home, so i think i'm compiling with a newer version of java than i'm running with.
Reminder: i want to build with a specified java home property = i want to change the compiler java home(or version) to the specified one. (In eclipse)
I would appreciate any help.
I dont think it is configurable. It is part of the Maven Core to use the JAVA_HOME environment variable. Please see the accepted answer of:
How to set specific java version to Maven
Also it is not possible to set or change environment variables (not system properties) within a Java process (for the current process). If you create another process from within your Java process, there will be methods to specify environment variables for this sub process.
Maybe the solution will be to execute a Maven command e.g. "mvn clean install" with a specific JAVA_HOME variable set as sub process (this requires, that Maven is installed and mvn is available as command). Use the ProcessBuilder to switch into the working directory, where the pom.xml of the target project is located and set the appropriate environment variable(s) before starting the process.
If Maven should not be installed at the enviroment your application is running on, you could also distribute a Maven installation with your application (maybe in a separate directory). Then you could run against the mvn.bat or mvn.sh of this distribution (depending on the os).
When using Eclipse, Build in Run as Configuration, go to the Environment tab and add the new JAVA_HOME variable.
Do not forget to check the Replace native environment ..... option.
This will override your default OS variable. No need to change at the OS level.
I have a Netbeans Platform modular project, not a regular Java project. I want to set VM options to increase memory, but under the "properties" dialog, there is no way to do this for a modular Netbeans platform project. This has cost me huge amounts of time and I still have not found a good way to set the VM args.
Does anyone know how to set VM args using a Netbeans platform modular project, when compiling and running the program in Netbeans 7? Given the amount of trouble, I am almost ready to give up on Netbeans to create modular applications.
It is quite easy, in fact. Just modify project.properties file to include the following line:
Edited:
run.args.extra=-J-Xmx768m
Of course, you can include any other JVM options there.
Enjoy.
I was finally able to solve this based on information at https://web.archive.org/web/20130830023832/http://activeintelligence.org/blog/archive/gephi-increasing-xmx-memory-in-netbeans/
What I did was modify the project.properties file, as JB said, but the correct way to do it was to add a -J before the args. E.g.,
run.args.extra=-J-Xms256m -J-Xmx756m
That did it! Not sure why it took 3 months to figure that out. Definitely a fail for the Netbeans documentation. They should really make this editable from the properties menu instead of making users hunt through nondescript config files!
I thought i'll put some contribution on this topic, When I was developing a netbeans platform application i also faced the same problem, I added run.args.extra=-J-Xmx768m
and updated my project.properties file but it didn't ! But when i added run.args.extra=-J-Xmx768m in my platform.properties file then it worked, again this only works when i was in development environment. When I packeged the application for windows the problem remained same my min heap size was 24m and max is 64m. Then I found out that if I update and add default_options="--branding my_project -J-Xms64m -J-Xmx1G" in my_project.conf in my installed directory C:\Program Files\my_project\etc then run my application and checked the ide log i can now see the change. By the way i wasn't lucky enough to see even the run node when i right click and go to the project properties dialogue in netbeans 7.0.1. Its upto netbeans dream team to make us feel lucky.
I had this issue and after some digging around and reading a lot of docs I was able to deduce that most of those values were coming from templates in the harness.
So if you go to your IDE_home/harness/etc/ you will find the "app.conf" file. This file is renamed during a distro build and the "app.conf" becomes your "application name.conf". Edit this file with the default values you would like in you application.
In my case I replaced the line that read:
default_options="--branding ${branding.token} -J-Xms24m -Xmx64m"
with
default_options="--branding ${branding.token} -J-Xms64m -Xmx512m" as my application was needing more memory. By changing the template I dont have to touch every deployment and change the memory CLI for the VM.
Hope this helps!
For maven projects:
As described in this question, you can use etcConfFile parameter of nbm-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<configuration>
<etcConfFile>src/main/resources/app.conf</etcConfFile>
</configuration>
</plugin>
More info: Geertjan's Blog
you have to add these lines to your project properties file.
<target name="build-launchers" depends="suite.build-launchers">
<replace file="build/launcher/etc/${app.name}.conf" token="--branding graphsimulator -J-Xms24m -J-Xmx64m" value="--branding graphsimulator -J-Xms128m -J-Xmx512m"/>
</target>
If you want to use Netbeans to set the VM options without bothering about which file to edit, here we go:
Run -> Set project configuration -> VM Options
Add your option in the corresponding text box for example: -Xms10m
To answer user1156544 doubt:
I'm writing a Java library with a lot of jni code. Pretty much every test case needs to load my jni dll, and I have a lot of test cases. In order to run the test cases out of Eclipse's Junit launcher, I have to create a run/debug configuration and edit the VM arguments and environment variables.
I would like a way to set the VM arguments and environment variables to a default for the entire project and have new run configurations include the default entries. From what I can tell, Execution Environments maybe do something like this but I seem to need the PDE to get them to work(?)
Specifically, I want to enable assertions on my project by default and include the path to my native dll in the PATH environment variable. I can't use the "Default VM Arguments" setting in the JRE definition panel because my dll depends on a number of others and java.library.path isn't used for dependency resolution, PATH is. Is there a way to make Eclipse do what I want?
So, here's what I did.
First, my specific problem was that I have a lot of run configurations, I create new ones on the fly, and I needed certain system properties set for unit tests. Setting them under the 'args' tab of run configurations was undesirable for my workflow. Also, I wanted the same command-line args set for all of my tests. I also don't run my app from inside eclipse. It's a dev-environment only.
So my solution was to add it to the command-line of my JRE. Preferences -> Java -> Installed JREs. Clicking edit gives you a window where you can specify default VM args. I just set the system properties I need for testing there.
Hope this helps.
How long does it take to run all of your tests for the project?
If the answer is Not long then create a project-wide JUnit launcher. If occasionally you would need to do a run on a single test case ( in order to debug or something ), you can copy all your settings from the project's junit launcher. I think you can even clone your project launcher to run a specific test case.
Run->Run Configurations...
Create new JUnit launcher.
On 'Test' tab select Run all tests
in selected {...}
Connfigure JVM options, classpath,
environment etc. for this launcher
Optional, but highly recommended. On
Common tab -> Save as -> Shared
file, and check-in launcher with
your project
One more thing I would do is to define a system property in launcher VM arguments, check for this property in #Before function and throw exception if the property is not set. This way you will know that your test fails because it is not using the right launcher.
If I understand your question correctly, I think Alexander is on to the idea with cloning the project launcher. Eclipse lets you duplicate launch configurations with a single click - simply setup one configuration with the parameters you require and click the button in the top left to duplicate it whenever you create a new one.