why does buckminster not resolve my passed JVM argument? - java

I have a jenkins job which uses buckminster to build an eclipse product.
At the beginning I have an "Extended Choice Parameter" where the "customer" key can be selected.
In the buckminster configuration I use this "customer" variable to select the right cquery:
import '${WORKSPACE}/source/scodi-customer/${customer}/server/features/ch.scodi.${customer}.server.feature/site.cquery'
Since the variable "customer" is per default not available in the commands, I added the following to the "JVM arguments":
-Dcustomer=${customer}
This all used to work well, but now I updated the server and build environment from Java 1.7 32-Bit to Java 1.8 64-Bit.
Since then I get the following error trying to build:
java.io.FileNotFoundException: [Path to job]\source\scodi-customer\${customer}\server\features\ch.scodi.${customer}.server.feature\site.cquery (The system cannot find the path specified)
Before the variable was resolved fine.
Is this a buckminster or java8 problem, not being able to resolve the ${customer} variable? Is there maybe another (cleaner) way to pass the variable to the buckminster configuration?
Edit: I did some further testing and added the following to the JVM arguments, I get the same exception referring to a missing ${customer}. It looks to me that JVM arguments are ignored.
-Dcustomer=CUSTOMER

Finally I found a workaround.
I had to rename my "customer" variable to "CUSTOMER", now it is resolved in the buckminster command area.
From:
import
'${WORKSPACE}/source/scodi-customer/${customer}/server/features/ch.scodi.${customer}.server.feature/site.cquery'
To:
import
'${WORKSPACE}/source/scodi-customer/${CUSTOMER}/server/features/ch.scodi.${CUSTOMER}.server.feature/site.cquery'
Also my JVM parameters from:
-Dcustomer=${customer}
To:
-Dcustomer=${CUSTOMER}
Found out the JVM parameters are not relevant to the buckminster command interface but are used later in "cspex" files.
Running Jenkins on a Windows machine this might cause this issue...
So the actual problem was the naming of the "Extended Choice Parameter", not being capitalized.

Related

cannot execute java class from bash script and also updatd the java_home to higher version and compiled the class in the lower version than mentioned

I had SunOs 5.10 unix server , where i had written a script to execute a java file which is as below
#!/bin/ksh -x
export JAVA_HOME=openjdk1.8.0_331/bin
$JAVA_HOME/java com.myclass.MyClient
in this script there is alot of code which includes log file, and other binaries class path added before exporting JAVA HOME. But when i am executing i am getting the below error
openjdk1.8.0_331/bin/java : Cannot execute
i had changes lot of java versions but getting the same error
Your JAVA_HOME is not an absolute path. This is broken; many tools will just fail when you do this. Just make it an absolute path. It may or may not explain your error, but it's a ticking timebomb.
JAVA_HOME cannot be bin; its the level above bin.
It looks like you're using JAVA_HOME as an ersatz script variable to make your script work, but this is wrong: JAVA_HOME is used by all sorts of tools and has a very specific meaning, and it's not whatever you think it is.
There are 2 obvious explanations for your error:
Some tool sees JAVA_HOME, attempts to run java based on this, and fails, because your JAVA_HOME is broken. There's a ton of infra that is 'custom' per OS, and it may well be that the SunOS setup didn't fail if you set JAVA_HOME to broken values, but it does fail here. The fix is to not have broken JAVA_HOME, not to start looking for a setup on your new OS that can deal with broken JAVA_HOME settings. In other words, your script was always broken, it just so happens that your specific set up on that specific server on that specific version of sun OS so happened to be capable of dealing with the mess.
A much simpler explanation is also possible: That executable does not run on your OS+Architecture combination. trivially testable: Do NOT set JAVA_HOME at all and just try to run that java executable by e.g. cd ing to the path and running ./java -version. See what happens. If that also gives you cannot execute, voila - the script isn't the problem (though it still has a broken JAVA_HOME you should be fixing), you need to install a JVM that works on your OS+Architecture.

You are using an outdated version of Java (11). Java 17 or higher is required

I got this error message but I have no idea how to get rid of it. I installed Java 18 and created a variable so I am out of ideas.
The error
Did I do the variable correctly?
Can u try to go to control panel/Apps and look for java 11 software then uninstall?
You also have to change your PATH variable. As You can see in the image the PATH Points to jdk11.
JAVA_HOME has to be set for the tooling chain (maven, gradle, a.s.o.). You should change your PATH to meet: %JAVA_HOME%\bin. (Sorry I used Windows long time ago and don't remember exactly how to dereference environment variables).
This whole thing works like this: The PATH variable is used by your OS to tell where executables can be found. When you type a command in terminal, all this locations are searched. First come, first server. So if you have two JDK,s defined in your path, the first one wins. So you can avoid this by defining the PATH entry by dereferencing JAVA_HOME.
To test in your terminal which java is used type java --version. Changes of environment variables are only valid for terminals opened after the change. Old terminals hold the old values. If You are not sure do a reboot after changing the variable.
Have a look at https://www.codejava.net/java-core/how-to-set-java-home-environment-variable-on-windows-10 . There you have a good explanation what happens.
I hope this help, 2 step to configure jdk to machine in User Variable and System Variable. And remove the previous software of jdk in the machine.

How to externalize the properties of a jacoco javaagent

I'm trying to get code coverage data from a remote server, so I added a JVM argument:
-javaagent:/opt/jacocoagent.jar=output=tcpserver,port=6300,includes="a pretty long list"
but unfortunately the includes list is too long, that the java command has exceeded the maximum length of our system limits.
Is there any way to specify a external property file so I can put the long "includes list” there?
I've read the jacoco document, it seems when running in "Offline Instrumentation", the jacoco agent will read properties from jacoco-agent.properties if it appears in classpath. But I don't want to use this mode.
Found a solution myself.
When oracle JVM startup, it picks an environment variable JAVA_TOOL_OPTIONS and
the JNI_CreateJavaVM function (in the JNI Invocation API) prepends the
value of the environment variable to the options supplied in its
JavaVMInitArgs argument.
So in my case, I defined:
JAVA_TOOL_OPTIONS=-javaagent:/path/to/jacocoagent.jar=output=tcpserver,address=*,port=6300,includes="a pretty long list"
For details, you can refer to:
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html

'javac' is not recognized as an internal or external command

I have to convert my Matlab algorithm in Java. For this I'm using matlab builder ja toolbox, after following all the necessary steps, the build fails and this error is displayed:
'javac' is not recognized as an internal or external command, operable program or batch file. Error: An error occurred while shelling out to javac (error code = 1). Unable to build executable.
When typing java -version in the matlab command line, this is what i get:
Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
It means I should have this compiler of java installed on my computer, only then the matlab builder ja works. I'm new to Java, I'm not sure what compiler I should be looking for.
First make sure you have installed jdk and jre, both are installed with the java software development kit. The installation folder is typically C:\Program Files\Java.
Now go to Computer > Properties > Advanced system settings in the advanced tab click on Environment Variables
In System variables find the variable named Path, in the value of Path you will find a java path like C:\ProgramData\Oracle\Java\javapath, just change it to C:\Program Files\Java\jdk1.x.x_x\bin.
Hope that helps.
If you want javac (the compiler), you'll need to download the Java Development Kit (JDK), not just the Java Runtime Environment (JRE). Note that the JDK includes a JRE.
This tutorial give instructions to install JDK to your computer.
You need to make sure that Java SDK is installed and also PATH is set properly so that windows would be able to know where the executable is. Detailed steps on how to debug this issue is explained here: http://www.windows-commandline.com/javac-not-recognized-internal-external-command/
To solve the aforementioned problem follow the mentioned steps:
1) Copy the address location of your Java\jdk\bin folder usually installed in your C: drive. It should look something like this:
C:\Program Files (x86)\Java\jdk1.8.0_65\bin
2) Right click on My Computer-->Properties-->Change settings-->
Advanced-->Environment Variables.. -->New..
3) Now,
Set Variable name: PATH
Variable value: C:\Program Files (x86)\Java\jdk1.8.0_65\bin
4) Press OK, re-open your cmd and compile your program.
Hopefully it worked!
Path is defined as the filename. Ex, C://aklsej;dlfkj/blahblah
You will need to specify the full path in the system control panel, advanced system settings, edit variables, edit path, put a semicolon after the last entry and don't delete anything, and then add the full path wherever you installed java to.
to make this easy, do a search for javac in the search panel and then just add the full path to the environmental variables from there.
Set Following Environment Variables
It will works
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_09
set PATH=%JAVA_HOME%\bin
Download Java from given link according to your requirements.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
then follow below steps:
Step-1 : Right Click on MyComputer and click on properties .
Step 2 : Click on Advanced tab
Step 3 : Click on Environment Variables
Step 4 : Create a new class path for JAVA_HOME
Step 5 : Enter the Variable name as JAVA_HOME and the value to your jdk bin path ie c:\Programfiles\Java\jdk-1.6\bin and
NOTE Make sure u start with .; in the Value so that it doesn't corrupt the other environment variables which is already set.
Step 6 : Follow the Above step and edit the Path in System Variables add the following ;c:\Programfiles\Java\jdk-1.6\bin in the value column.
Step 7 :Your are done setting up your environment variables for your Java , In order to test it go to command prompt and type
java
who will get a list of help doc
In order make sure whether compiler is setup Type in cmd
javac
who will get a list related to javac
Hope this Helps !
If you receive this error, Windows cannot find the compiler (javac).
Here's one way to tell Windows where to find javac. Suppose you installed the JDK in C:\jdk1.8.0. At the prompt you would type the following command and press Enter:
C:\jdk1.8.0\bin\javac HelloWorld.java
If you choose this option, you'll have to precede your javac and java commands with C:\jdk1.8.0\bin\ each time you compile or run a program. To avoid this extra typing, consult the lecture "Creating a Hello World application" in this website
Class names, 'HelloWorld', are only accepted if annotation processing is explicitly requested
If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorld.java not javac HelloWorld.

Does jna.library.path use any environment variables?

On OS X 10.8.2, I'm using JNA and gstreamer-java (through the Eclipse IDE) to load gstreamer libraries. At first I installed gstreamer using the SDK provided by gstreamer.com. However, I uninstalled this and use Macports to install it.
The SDK's libs were installed to:
/System/Library/Frameworks/GStreamer.framework/Versions/0.10-x64/lib
But that directory no longer exists.
Where Macports installed the libs to:
/opt/local/lib
Now, say I want to set java to know of this location via some environment variable. Is this possible? It seems so, because running this line:
System.out.println( System.getProperty("jna.library.path"));
Shows /System/Library/Frameworks/GStreamer.framework/Versions/0.10-x64/lib. But I cannot for the life of me figure out where that got set. It's not set as a runtime VM argument. My $PATH and $DYLD_LIBRARY_PATH, $LD_LIBRARY_PATH do not have this directory set. They actually have the path I want, /opt/local/lib/ set which has no effect it seems. Running env shows no variables with the Framework path either.
So, jna.library.path. Is it set externally? How can I change it--without setting it at runtime or via java command-line arguments? Zero points for telling me to symlink.
EDIT:
Searching through gstreamer-java's files led me to gstreamer-java.spec, which has this line:
sed -i [...] -e "s,\(run.jvmargs=-Djna.library.path=\).*,\1%{_libdir}:$(pkg-config --variable=pluginsdir gstreamer-0.10),"
Running the contained command pkg-config --variable=pluginsdir gstreamer-0.10 gets me this:
/opt/local/lib/gstreamer-0.10
Which is the correct path for plugins. Further running pkg-config --print-variables gstreamer-0.10 gives me all these:
typelibdir
datarootdir
exec_prefix
pluginsdir
datadir
prefix
libdir
includedir
girdir
toolsdir
Which are all at or under the correct /opt/local/ directory.
Have you tried running outside of Eclipse?

Categories