I am trying to work with args4j. I created a dummy project that contains one single command line option called 'enableAuth'. See Features.java.
I tried to run this in eclipse with run configuration > program arguments as --enableAuth=true, -enableAuth=true, -enableAuth true etc., But none of them work for me. I run into CmdLineException always.
Any help is appreciated. Github project: https://github.com/seshumadhav/java-projects/tree/master/args4j-demo
For boolean fields I don't think we are suppose to give values(i.e. true/false). Just pass the argument as a flag
java XXX.java -enableAuth
If the field was non-boolean than it would have expected a value.
Related
Below is the command cmd that is going to get executed and is working fine.
def process = cmd.execute(['PATH=D:/Project/Node_Project/build/nodejs/node-v10.10.0-win-x64'],null)
"D:/Project/Node_Project" is my project root folder.
I am trying something like below to make the path generic but it didn't work. ${project.buildDir} also didn't work.
def process = cmd.execute(['PATH=${project.projectDir}/build/nodejs/node-v10.10.0-win-x64'],null)
I want to know what is the correct format to make it generic.
https://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/String.html#execute(java.lang.String[],%20java.io.File)
The above link contains the documentation for the syntax only but no examples to solve my problem.
I am having the following problem:
I have an Enum that was originally declared with 5 elements.
public enum GraphFormat {
DOT,
GML,
PUML,
JSON,
NEO4J,
TEXT {
#Override
public String getFileExtension() {
return ".txt";
}
};
Now I need to add an additional element to it (NEO4J). When I run my code or try to debug it I am getting an exception because the value can't be found in the enum.
I am using IntelliJ as my IDE, and have cleaned the cache, force a rebuild, etc.. and nothing happens. When I look at the .class file created on my target folder, it also has the new element.
Any ideas on what could be causing this issue ?
I found my problem and want to share here what was causing it. My code was actually for a Maven plug-in which I was pointing to another project of mine to run it as a goal. However the pom.xml of my target test project was pointing to the original version of the plug-in instead of the one I am working on, and that version of course is outdated and does not include the new value. Thank you.
Is there a way to see the spark-launcher CLI command that will be submitted to spark when using the following line in JAVA to send an already configured spark launcher?
SparkLauncher().launch();
Edit: The method "createBuilder" within "SparkLauncher.class" seems to have it, as a list, during the ".launch()" process.
Now this is a matter of finding the way to extract that information from the point there the "SparkLauncher().launch()" is being submitted.
Given you define your sparkLauncher as: "launcher"
You can get the spark-submit command this way:
String sparkSubmitCommand = StringUtils.join(launcher.createBuilder().command(), " ");
I thought this would be a very simple thing. So far however I'm unable to access the String for my gradle job's Java.Home, the official name:
For example, see: org.gradle.java.home
Apparently I can set this value with gradle.properties settings file. I've done that and the gradle output confirms this.
For all that, none of these print statements work...
print "org.gradle.java.home = $org.gradle.java.home"
print "org.gradle.java.home = "+ project.properties['org.gradle.java.home']
print "org.gradle.java.home = $gradle.java.home"
print "${project.property('org.gradle.java.home')}"
Looking at back at this question, I would have thought one of the options tried would yield a result.
How can I access system level properties?
Only two options may work:
print "org.gradle.java.home = "+ project.properties['org.gradle.java.home']
print "${project.property('org.gradle.java.home')}"
and the second will fail since there's no checking if such property exists. Gradle throws an exception on access to non-existing property.
The last two will not work because there's no property org and gradle objects has no java property - more explanation can be found here - you need to understand how string interpolation works with groovy.
And finally, these properties are used to pass arguments to gradle. So the following will work:
print "org.gradle.java.home = "+
project.properties['org.gradle.java.home']
run with:
gradle -Dorg.gradle.java.home=random_dir
With some trial-and-much-error, I have found that one may print the java.home property on Windows with Gradle 2.4; when ...
Use your gradle.properties file, e.g.
For example
compile.options.fork = true
org.gradle.daemon = true
org.gradle.java.home = b:/lang/java/jdk/v1.8u45
The same settings in GRADLE_OPTS had no effect. The print command used, is:
print "org.gradle.java.home = "+ "${project.property('org.gradle.java.home')}"
I believe the compile.options.fork is also required. It had no effect before when I was using GRADLE_OPTS. Although the Gradle message to use fork is quite clear on the matter.
see also:
- https://docs.gradle.org/2.4/userguide/gradle_daemon.html
EDIT: Code for InstallCerts is here:
http://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java
I am trying to run a java program in eclipse that takes a URL (eg https://myurl.com) as an argument. When I go to Run Configurations -> Arguments and paste in the URL, it looks fine. I click Apply.
The problem starts when I click Run. For some reason, eclipse removes the https: at the start of the URL and I get an error saying:
Exception in thread "main" java.lang.NumberFormatException: For input string: "//myurl.com"
Notice the lack of https:?
Anyway, if someone can point me in the right direction to resolve this, I'd be very grateful.
I should also point out, I tried to create a Variable as well, to hold the URL, but I got the same error. Likewise when I quoted the URL.
Thanks.
You are getting a "NumberFormatException" which means you are trying to convert a String to int in your code . I think thats the real problem.
Quote it.
"https://myurl.com"
EDIT : I just tried quote/unquote - it works either way. Can you post your code?
Cheers,Eugene
The trick is that class searches for port. Do not use https://, instead refer to secure port e.g. my.site.com:443!