Jenkins Maven how to fix wrong command - java

Learning Jenkins. Windows 7 running jenkins-2.73.3, a maven project gives following output:
20:29:11 [test] $ "C:\Program Files\Java\jdk1.8.0_102/bin/java" –Xmx1024m –XX:MaxPermSize=256m -cp "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-agent-1.12-alpha-1.jar;C:\Apps\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;C:\Apps\apache-maven-3.3.9/conf/logging" jenkins.maven3.agent.Maven33Main C:\Apps\apache-maven-3.3.9 "C:\Program Files (x86)\Jenkins\war\WEB-INF\lib\remoting-3.10.2.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-interceptor-1.12-alpha-1.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.12-alpha-1.jar" 50129
20:29:11 Error: Could not find or load main class –Xmx1024m
20:29:41 ERROR: Failed to launch Maven. Exit code = 1
20:29:41 Finished: FAILURE
The problem is obvious: java takes -Xmx1024m as the main class. But the command is generated, how can I move "-Xmx.. -XX:Max.." to the end of the command?

Removing "–Xmx1024m –XX:MaxPermSize=256m" from Maven Project Configuration / Global MAVEN_OPTS on Jenkins fixed the issue.

Related

VS Code Showing 'mvn' is not recognized as an internal or external command

I'm trying to create a maven project with VS Code but when I run the command it says :
'mvn' is not recognized as an internal or external command,operable program or batch file.
but mvn -version is running on command prompt
Environment varaible for User :
MAVEN_JOME : C:\apache-maven-3.6.1,
M2_HOME : C:\apache-maven-3.6.1,
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_212\jre and
System Variables
path is set to C:\apache-maven-3.6.1\bin, C:\Program Files\Java\jdk1.8.0_212\bin for maven and java respectively.
The command I'm running to create the project is:
mvn archetype:generate -DgroupId=com.cs.test-project -DartifactId=test-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false The Reference to Command
And the VS Code Reference to Command
The same command is running in Command prompt and it created the project successfully on Desktop.
I fixed this problem by simply restarting VSCode as I had set my PATH variable while my VSCode was running so the changes were not reflected to the VSCode integrated terminal until I restarted it.
It's kindy counterintuitive as path has to be pointed to the actual mvn command, instead to a M2_PATH folder. Also once properly pointed, a new error will be shown if your environment is missing proper jdk within JAVA_HOME. The error is trown by maven. Maven plugin is kinda stupid as it will ignore your default JDK configured within settings.json (java.home or/and java.configuration.runtimes properties) and will happly NOT set java for maven. You have to configure it specificly for maven plugin as this:
"maven.executable.path": "c:\\apache-maven-3.8.1\\bin\\mvn",
"maven.terminal.customEnv": [{
"environmentVariable": "JAVA_HOME",
"value": "c:\\openjdk-1.8.0_232-redhat",
}]
Of course, both paths should be pointed to proper folders/files in your environment.
The way I fixed was by changing the exec path in Vs Code settings from CMD to Powershell.
Open
settings -> features -> terminal
Change the windows exec path from cmd to where you have PowerShell.
For example: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Windows exec setting
On Tuesday Oct. 25, 2022 while trying to solve the same problem, I went through all of these previous solutions for Windows and finally had to resort to the official installation docs:
Installing Apache Maven
Unzipped the download and located the bin directory and manually added that directory location to my: System Properties>Advanced>Environment Variables>'Path'
For good measure, restart the computer.

Jenkins not executing Windows Batch command java x.y.file$test

Been searching all day for why Jenkins does not execute a Windows batch command
java x.y.java$Test
If you open windows cmd and execute java x.y.java$Test it works just fine. I can execute the cmd from any directory and the java is executed.
CLASSPATH is the same when I view Jenkins Environment variables or the systems variables. I'm running Windows 7
Running Jenkins 2.138.1
Here is the error message:
Error: Could not find or load main class bichromate.core.sTestCleanupFactory$Test
any suggestions would be helpful
So it works in jenkins if you add the -cp
EXAMPLE: java -cp path to the class then the qualified class file

Given that NetBeans is installed, how can I use ant from the command-line (on Windows)?

I have NetBeans 8.0.2 installed on my Windows 7 (64-bit) machine. I have also the JDK installed (Java SE Development Kit 8 update 66 (64-bit)).
I want to run ant from the command line, but the closest I think I've come to getting it to run is the following:
java -jar "C:\Program Files\NetBeans 8.0.2\extide\ant\lib\ant.jar"
but I got the error
Error: Could not find or load main class org.apache.tools.ant.Main
I also tried the following, thinking that Main.class might be inside ant.jar, but got the same error:
java -cp "C:\Program Files\NetBeans 8.0.2\extide\ant\lib\ant.jar" -jar "C:\Program Files\NetBeans 8.0.2\extide\ant\lib\ant.jar"
I've spent at least an hour searching online and StackOverflow for the anser. The closest I've found is Compile NetBeans project from command line by using Ant, but it assumes that ant is accessible from the command line already.
To set up ant to work from the command line
Add C:\Program Files\NetBeans 8.0.2\extide\ant\bin to your PATH
Add the environment variable JAVA_HOME with the value C:\Program Files\Java\jdk1.8.0_66 (adjust this if you end up using a different version, of course).
Now that it is set up, simply use ant from the command line normally.
To rebuild the project, for example, simply do the following:
Open a new command prompt
Go to the project directory
Type ant clean jar

Ant Path error when performing Apache Cordova Helloworld example for amazon-fireos

I am working through Apache Cordova Amazon-fireos guide
But I am getting an Ant path error when performing "cordova platform add amazon-fireos" command. Looking at the code it looks like it is doing a pre-req check and trying to execute ant -version but failing. I then tried skipping that pre-req only for it to then error out when it tries to execute java -version. But after the cordova command errors out I can type ant -version and java -version and both commands execute successfully, see screenshot below.
I am running Windows 7 Pro 64bit and my path variables looks like this:
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_51
ANT_HOME = c:\apache-ant-1.9.3
PATH=C:\Program Files\nodejs;%ANDROID_HOME%;%ANDROID_TOOLS%;
C:\Users\Super\AppData\Roaming\npm;%JAVA_HOME%\bin;%ANT_HOME%\bin
Here is the screenshot from running the command with the -d option.
It turns out I must of accidently deleted c:\windows\system32 from the PATH variable and so it could not find the cmd command. Added the path c:\windows\system32 back in and I no longer receive the Ant error.

Building android-maven project in netbeans

I am trying to get up and running a new android-maven project in Netbeans 7.1.1. I keep getting this error
Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:dex (default-dex) on project myproject: MojoExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C ""C:\Program Files\Java\jdk1.7.0_03\jre\bin\java" -Xmx1024M -jar "C:\Program Files\Android\android-sdk\platform-tools\lib\dx.jar" --dex "--output=C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\MyProject\target\classes.dex" "C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\MyProject\target\classes"", Result = 1 -> [Help 1]
This is the pom file: http://pastebin.com/k1ZzfEYY
No. You don't have to downgrade to a Java 6 SDK from Java 7 SDK to use Maven with Android.
The problem is that after you made some updates with the SDK Manager something got corrupted and you no longer have the dx.jar file in your android-sdk\platform-tools\lib folder, and when you try to build with Maven your project doesn't have that jar in the path and it fails to build.
To fix this you need to open the SDK Manager and delete the "Android SDK Platform-tools" that you currently have installed and reinstall it. After that go to the android-sdk\platform-tools\lib folder and see if the dx.jar file is there and try to build your project with mvn clean install android:deploy.
I've tested this with the sample helloflashlight application and it worked correctly after I've reinstalled the platform tools.
Also make sure that you have the environment variables JAVA_HOME, ANDROID_HOME, M2_HOME pointing to the right paths.

Categories

Resources