Gradle not able to install properly - classpath

I am trying to install the gradle 1.3 on window 7 machine and did the following steps
1.Downloaded the gradle-1.3.all.zip from http://www.gradle.org/ url
2.Extracted it to F:\localRepository\gradle-1.3
3.Set the environment variables
GRADLE_HOME=F:\localRepository\gradle-1.3
GRADLE_OPTS=F:\localRepository\gradle-1.3\bin
PATH = F:\localRepository\gradle-1.3\bin;F:\jdk1.7.0_21\bin
JAVA_HOME=F:\jdk1.7.0_21
JAVA_OPTS=F:\jdk1.7.0_21\bin
4.RUN gradle in CMD
5.getting
"Could not find or load main class F:\jdk1.7.0_21\bin"
Can anyone suggest me what I am missing here?

Those JAVA_OPTS look suspicious to me. What are you trying to achieve by setting them to that?
If you look at gradle.bat (in F:\localRepository\gradle-1.3\bin) you'll see this line which actually launches Java to run Gradle:
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.launcher.GradleMain %CMD_LINE_ARGS%
So as far as Java's concerned, your %JAVA_OPTS% looks like the name of the main class. Everything after that just gets parsed as parameters.
JAVA_OPTS is for the parameters you want to pass to the JVM.
Your GRADLE_OPTS also looks a bit unusual.

about the JAVA_OPTS and GRADLE_OPTS I'm citing from Gradle documentation:
JVM OPTIONS
JVM options for running Gradle can be set via environment variables. You can use GRADLE_OPTS >or JAVA_OPTS. Those variables can be used together. JAVA_OPTS is by convention an environment >variable shared by many Java applications. A typical use case would be to set the HTTP proxy >in JAVA_OPTS and the memory options in GRADLE_OPTS. Those variables can also be set at the >beginning of the gradle or gradlew script.
http://www.gradle.org/installation
But in general it's not suitable placeholder for bin folder. You better define your Path variable as:
Path=%JAVA_HOME%\bin;%GRADLE_HOME%\bin;
and remove or redefine your JAVA_OPTS or GRADLE_OPTS variables.

Related

Configuring SBT global settings

I need to permanently turn on the -verbose setting for SBT, without having to type it each time. What's the best way to do this? Putting -verbose in $SBT_OPTS does not have an effect.
-verbose flag can be enabled system-wide by saving it in global sbtopts configuration file. For example, on my machine, it is located at
/usr/local/etc/sbtopts
Here is an example of its contents
# set memory options
-mem 2048
# java version (default: java from PATH, currently $(java -version |& grep version))
-java-home /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
-verbose
Addressing the comment regarding IntelliJ, note that IntelliJ Scala Plugin currently does not read global sbtopts, however it does have support for local .sbtopts configuration file, but it does not support every option provided by sbt launcher script proper:
Supported options:
-no-share, -no-global, -sbt-boot, -sbt-dir, -ivy, -jvm-debug,
all options with -D and -J prefixes
Unsupported options:
-S prefix seems to be unsupported by sbt-launcher itself
-mem has a bit untrivial algorithm, same thing can be achieved
by configuring -Xmx, -Xms, -XX:ReservedCodeCacheSize options
-sbt-version, -sbt-rc, -sbt-snapshot, -sbt-jar
and -java-home are overriden by IDEA options
Other options have no impact on project importing process
SbtOpts.scala should list all the supported options. One notable absence is support for -mem, which means if we put, say, -mem 4096 in .sbtopts, then IntelliJ will simply ignore it. Similarly, the flag -verbose will not be picked up by IntelliJ sbt runner.
Hence the key is to understand that sbt runner script proper is not the same as IntelliJ custom made sbt runner component.
if you use unix friendly environment, you can create an alias for sbt in your ~/.bash/profile for example
alias sbt=sbt -verbose

Scala sbt -D environemt variable not found

I am trying to access an environment variable in my sbt build file.
As told I set the environment variable with the jvm -D Option
sbt -DaccessToken=***** compile
but scala cannot find the variable
sys.env.get("accessToken").getOrElse(throw new RuntimeException("System variable 'accessToken' with the credentials is not set."))
Why does the -D option have no effect?
If I set the variable with export in linux everything works fine.
Anything you pass as -D is not environment variable and cannot be read as sys.env.get.
You need to use Java API to read them
System.getProperty("accessToken")
Other option is to assign an environment variable before you launch your sbt. In bash, for example, it can be done like this but this, of course, depends on your environment.
accessToken=***** sbt compile

Java Illegal Argument Exception thrown when opening NetLogo model in Jython

I am trying to control NetLogo's API using Jython 2.7.0 (on Java 1.8.0_131) running on OS X El Capitan (10.11.6) to run experiments. In trying to run the following code:
import site
site.addsitedir("/Users/nqe/NetLogo/NetLogo 6.0.1/Java/")
import org.nlogo.headless.HeadlessWorkspace as hw
workspace = hw.newInstance()
workspace.open("models/Sample Models/Earth Science/Fire.nlogo")
workspace.command("set density 62")
workspace.command("random-seed 0")
workspace.command("setup")
workspace.command("repeat 50 [ go ]")
print (workspace.report("burned-trees"))
workspace.dispose()
I get the following error:
at scala.Predef$.require(Predef.scala:264)
at org.nlogo.generate.PrimitiveCache$.read$1(PrimitiveCache.scala:22)
at org.nlogo.generate.PrimitiveCache$.$anonfun$getClassReader$1(PrimitiveCache.scala:26)
at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:80)
at org.nlogo.generate.PrimitiveCache$.getClassReader(PrimitiveCache.scala:26)
at org.nlogo.generate.PeepholeSafeChecker.processClass(PeepholeSafeChecker.scala:49)
at org.nlogo.generate.PeepholeSafeChecker.isSafe(PeepholeSafeChecker.scala:42)
at org.nlogo.generate.Generator$InstructionGenerator.generateInstruction(Generator.scala:190)
at org.nlogo.generate.Generator$InstructionGenerator.generateBodyMethod(Generator.scala:124)
at org.nlogo.generate.Generator$InstructionGenerator.generate(Generator.scala:99)
at org.nlogo.generate.Generator.org$nlogo$generate$Generator$$recurse(Generator.scala:29)
at org.nlogo.generate.Generator.$anonfun$recurse$1(Generator.scala:31)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:193)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:193)
at org.nlogo.generate.Generator.org$nlogo$generate$Generator$$recurse(Generator.scala:31)
at org.nlogo.generate.Generator.$anonfun$generate$1(Generator.scala:25)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:193)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:193)
at org.nlogo.generate.Generator.generate(Generator.scala:25)
at org.nlogo.compile.CompilerMain$.assembleProcedure(CompilerMain.scala:79)
at org.nlogo.compile.CompilerMain$.$anonfun$compile$2(CompilerMain.scala:55)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.immutable.List.foreach(List.scala:378)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.immutable.List.map(List.scala:284)
at org.nlogo.compile.CompilerMain$.compile(CompilerMain.scala:55)
at org.nlogo.compile.Compiler.compileProgram(Compiler.scala:52)
at org.nlogo.headless.HeadlessModelOpener.openFromModel(HeadlessModelOpener.scala:54)
at org.nlogo.headless.HeadlessWorkspace.openModel(HeadlessWorkspace.scala:532)
at org.nlogo.headless.HeadlessWorkspace.open(HeadlessWorkspace.scala:499)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: requirement failed
In case the "import site" part is not clear, I did the following:
Create a jython script to write all .jar files in "/Users/nqe/NetLogo/NetLogo 6.0.1/Java/" to a .pth file.
I then placed this .pith file into said the .../Java/ directory with the .jar files.
This allows me to access all the .jar dependencies from sys.path when needing to the import various API features of NetLogo.
I can't figure out exactly what causes this error, for in running on python interactive mode, I was able to successfully create a new instance of NetLogo JVM using the hw.newInstance() command (I could see a Java icon pop up when running this code), and the open command threw the appropriate errors if I fail to specify a url, for example.
Because of this, I thought it might have something to do with my JVM not being configured properly, so I tried a few things.
First, I checked that I was able to actually run the java example of controlling NetLogo API in headless mode found here: https://github.com/NetLogo/NetLogo/wiki/Controlling-API. I was able to run the code given here using these commands:
javadir=/Users/nqe/NetLogo/ControlAPI/
netjardir=/Users/nqe/NetLogo/NetLogo\ 6.0.1/Java/netlogo-mac-app.jar
javaname=Example1
javac -cp "${javadir}":"${netjardir}" $javaname.java
java -cp "${javadir}":"${netjardir}" $javaname
without changing any JVM settings manually. Nevertheless, I went ahead and tried changing things in my JVM settings when running the jython code such as the path to docs and extensions, but in particular, to the ./lib directory. Unfortunately, specifying the following JVM setting:
-Djava.library.path=~/JRE/Contents/Home/jre/lib/
does nothing to help the cause. Note that the ~ here is short for being in the NetLogo 6.0.1 directory and that this was the only lib directory I could find.
Finally, I discord this: when I try to run the above jython script when only specifying the path to netlogo-mac-app.jar, I AM NOT ABLE TO IMPORT the headless class stuff. Hence, the compilation/ running of the java while specifying only this one .jar classpath could possibly be somehow accessing some useful meta-data necessary for NetLogo to work (I don't know if this is possible with my level of Java background).
Upon thinking this, I found a NetLogo.cfg file in ~/NetLogo 6.0.1.app/Contents/Java/ that contains the following info:
[Application]
app.name=NetLogo
app.mainjar=netlogo-mac-app.jar
app.version=6.0.1
app.preferences.id=org/nlogo/app
app.mainclass=org/nlogo/app/MacApplication
app.classpath=$APPDIR/../../Java/args4j-2.0.12.jar:$APPDIR/../../Java/asm-5.0.3.jar:$APPDIR/../../Java/asm-5.0.3.jar:$APPDIR/../../Java/asm-all-5.0.4.jar:$APPDIR/../../Java/asm-all-5.0.4.jar:$APPDIR/../../Java/asm-analysis-5.0.3.jar:$APPDIR/../../Java/asm-analysis-5.0.3.jar:$APPDIR/../../Java/asm-tree-5.0.3.jar:$APPDIR/../../Java/asm-tree-5.0.3.jar:$APPDIR/../../Java/asm-util-5.0.3.jar:$APPDIR/../../Java/asm-util-5.0.3.jar:$APPDIR/../../Java/behaviorsearch.jar:$APPDIR/../../Java/commons-codec-1.10.jar:$APPDIR/../../Java/commons-codec-1.10.jar:$APPDIR/../../Java/commons-logging-1.1.1.jar:$APPDIR/../../Java/commons-logging-1.1.1.jar:$APPDIR/../../Java/gluegen-rt-2.3.2.jar:$APPDIR/../../Java/gluegen-rt-2.3.2.jar:$APPDIR/../../Java/httpclient-4.2.jar:$APPDIR/../../Java/httpclient-4.2.jar:$APPDIR/../../Java/httpcore-4.2.jar:$APPDIR/../../Java/httpcore-4.2.jar:$APPDIR/../../Java/httpmime-4.2.jar:$APPDIR/../../Java/httpmime-4.2.jar:$APPDIR/../../Java/java-objc-bridge-1.0.0.jar:$APPDIR/../../Java/jcommon-1.0.16.jar:$APPDIR/../../Java/jfreechart-1.0.13.jar:$APPDIR/../../Java/jhotdraw-6.0b1.jar:$APPDIR/../../Java/jhotdraw-6.0b1.jar:$APPDIR/../../Java/jmf-2.1.1e.jar:$APPDIR/../../Java/jmf-2.1.1e.jar:$APPDIR/../../Java/jna-4.2.2.jar:$APPDIR/../../Java/jogl-all-2.3.2.jar:$APPDIR/../../Java/jogl-all-2.3.2.jar:$APPDIR/../../Java/json-simple-1.1.1.jar:$APPDIR/../../Java/json-simple-1.1.1.jar:$APPDIR/../../Java/log4j-1.2.16.jar:$APPDIR/../../Java/log4j-1.2.16.jar:$APPDIR/../../Java/macro-compat_2.12-1.1.1.jar:$APPDIR/../../Java/macro-compat_2.12-1.1.1.jar:$APPDIR/../../Java/netlogo-6.0.1.jar:$APPDIR/../../Java/netlogo-6.0.1.jar:$APPDIR/../../Java/netlogo-mac-app.jar:$APPDIR/../../Java/parboiled-core-1.1.7.jar:$APPDIR/../../Java/parboiled-core-1.1.7.jar:$APPDIR/../../Java/parboiled-java-1.1.7.jar:$APPDIR/../../Java/parboiled-java-1.1.7.jar:$APPDIR/../../Java/parboiled_2.12-2.1.3.jar:$APPDIR/../../Java/parboiled_2.12-2.1.3.jar:$APPDIR/../../Java/pegdown-1.6.0.jar:$APPDIR/../../Java/pegdown-1.6.0.jar:$APPDIR/../../Java/picocontainer-2.13.6.jar:$APPDIR/../../Java/picocontainer-2.13.6.jar:$APPDIR/../../Java/rsyntaxtextarea-2.6.0.jar:$APPDIR/../../Java/rsyntaxtextarea-2.6.0.jar:$APPDIR/../../Java/scala-library-2.12.0.jar:$APPDIR/../../Java/scala-library-2.12.1.jar:$APPDIR/../../Java/scala-library-2.12.1.jar:$APPDIR/../../Java/scala-parser-combinators_2.12-1.0.5.jar:$APPDIR/../../Java/scala-parser-combinators_2.12-1.0.5.jar:$APPDIR/../../Java/shapeless_2.12-2.3.2.jar:$APPDIR/../../Java/shapeless_2.12-2.3.2.jar
app.runtime=$APPDIR/../../JRE
app.identifier=org.nlogo.app
[JVMOptions]
-Dnetlogo.extensions.dir=$APPDIR/../../extensions
-Dnetlogo.models.dir=$APPDIR/../../models
-Dnetlogo.docs.dir=$APPDIR/../../docs
-Xdock:name=NetLogo
-Dorg.nlogo.mac.appClassName=org.nlogo.app.App$
-Xmx1024m
-Dfile.encoding=UTF-8
-Dapple.awt.graphics.UseQuartz=true
[JVMUserOptions]
[ArgOptions]
This seemed promising, but literally deleting this file had no affect on my ability to run NetLogo by opening the application/ using the Control API with Java method. As such, I am stumped, so any help would be greatly appreciated.

Eclipse run error

When i try to run my code on Eclipse this error appears:
Usage: javaw [-options] class [args...]
(to execute a class)
or javaw [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
-hotspot is a synonym for the "server" VM [deprecated]
The default VM is server.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
i try to coment my entired code and this error still appear.
It seems you haven't set your java path correctly.
Setting Up Eclipse with Java 1.6 on Windows
How To Install and Get Started with Java Programming
Run eclipse in clean mode
Edit the eclipse.ini file located in your Eclipse install directory and insert -clean as the first line.
If this is happening to a specific project only and other projects are running fine then your default run configuration might have changed. You may try the following
- Run -> Run As -> 1 Java Application.
I fixed this issue by deleting some of my old runtime configurations. Eclipse then started automatically generating them again.

sbt: Unable to specify application configuration in mingw

I am trying to launch an application using sbt's application launcher.
This application is defined as:
#!/bin/sh
java -jar /home/salil.wadnerkar/.conscript/sbt-launch.jar #"/home/salil.wadnerkar/.conscript/n8han/conscript/cs/launchconfig" "$#"
However, when I launch it, it gives me this error:
$ ~/bin/cs n8han/giter8
Error during sbt execution: Could not find configuration file 'C:/MinGW/msys/1.0/home/salil.wadnerkar/.conscript/n8han/conscript/cs/launchconfig'. Searched:
file:/C:/MinGW/msys/1.0/home/salil.wadnerkar/
file:/C:/Users/salil.wadnerkar/
file:/C:/MinGW/msys/1.0/home/salil.wadnerkar/.conscript/
However, the file is present there. So, I think it's because of some quirk in the way sbt handles mingw file path.
Does anybody know how I can get it working?
In Cygwin I used
java -jar "`cygpath -m "$HOME/.conscript/sbt-launch.jar"`" "#file:///C:/Users/cvanvranken/.conscript/n8han/conscript/cs/launchconfig" "$#"
I expect you will be able to get yours to work with something similar, perhaps this:
java -jar /home/salil.wadnerkar/.conscript/sbt-launch.jar "#file:///C:/Users/salil.wadnerkar/.conscript/n8han/conscript/cs/launchconfig" "$#"
or
java -jar /home/salil.wadnerkar/.conscript/sbt-launch.jar "#file:///C:/MinGW/msys/1.0/home/salil.wadnerkar/.conscript/n8han/conscript/cs/launchconfig" "$#"
if those fail, you still definitely need to use the file:// protocol.
Also note the three directories it is searching in the error message
file:/C:/MinGW/msys/1.0/home/salil.wadnerkar/
file:/C:/Users/salil.wadnerkar/
file:/C:/MinGW/msys/1.0/home/salil.wadnerkar/.conscript/
no matter what you put in the launchconfig parameter, if it is not recognized then those directories are searched by default. So you could have gibberish in your parameter and still see the same exact error you are getting now.
you can set the launch config path relative to the .conscript folder -
java -jar /home/salil.wadnerkar/.conscript/sbt-launch.jar #n8han/conscript/cs/launchconfig "$#"