How to solve JDK issue unexpected at this time
Here are some ways to find the short name of a directory.
Windows CMD
dir /X "C:\Program Files (x86)*"
as VB script
' usage: cscript shortname.vbs [directory]
'
' example: cscript shortname.vbs "C:\Program Files (x86)\Java\jdk1.6.0_45"
on error resume next
Set fso=CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(WScript.Arguments(0))
Set objSubFolders = objFolder.SubFolders
For Each sf In objSubFolders
WScript.Echo sf.ShortPath
Next
Set objFiles = ObjFolder.Files
For Each file In objFiles
WScript.Echo file.ShortPath
Next
Java using JNA
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Kernel32;
public class LongToShort {
public static String GetShortPathName(String path) {
char[] result = new char[256];
Kernel32.INSTANCE.GetShortPathName(path, result, result.length);
return Native.toString(result);
}
// java LongToShort "C:\Program Files (x86)\Java\jdk1.6.0_45"
public static void main(String[] args) {
System.out.println(GetShortPathName(args[0]));
}
}
edit
Example how to change the JAVA_HOME environment variable.
Assuming your JDK is installed in C:\Program Files (x86)\Java\jdk1.6.0_45
.
The short name of C:\Program Files (x86)
might be PROGRA~1
.
Change your JAVA_HOME:
from set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45
to set JAVA_HOME=C:\PROGRA~1\Java\jdk1.6.0_45
Maven not running with Java 10: Files\Java\jdk-10""=="" was unexpected at this time
The messages start with "Files\Java\jdk-10" which seems to indicate you have not quoted your JAVA_HOME
correctly. The correct syntax would be something like
set "JAVA_HOME=c:\Program Files\Java\jdk-10"
set "PATH=%JAVA_HOME%\bin;%PATH%"
And then
java -version
should function without specifying additional arguments on the command line (as should maven).
cmd error "Common was unexpected at this time" to run Spark with Java
During the installation of Java, relevant information has been written into the windows registry,Moving the installation directory directly will cause the program to be unusable.
It is recommended to uninstall and reinstall in the control panel, and specify a directory without spaces.
Thank you!
Maven - "files was unexpected at this time"
Finally I was able to resolved the issue.
A quoted value in the user variables has caused to the "Files were unexpected at this time" error in maven.
I spent hours of time with changing Java_home and M2_home variables with different combinations but finally checked the user variable and noted the quotes there.
Home = "C:\Program Files (x86)\Git\bin"
Removed the quotes and change the git home variable as below and now all works fine. :)
Home = C:\Program Files (x86)\Git\bin
Related Topics
How to Convert Byte Array to String and Vice Versa
In Java Streams Is Peek Really Only For Debugging
Occurrences of Substring in a String
When Does Static Class Initialization Happen
Java: Date from Unix Timestamp
Why Is Volatile Used in Double Checked Locking
To Prevent a Memory Leak, the Jdbc Driver Has Been Forcibly Unregistered
Difference Between Javac and the Eclipse Compiler
How to Calculate Someone'S Age in Java
How to Set or Change the Default Java (Jdk) Version on Macos
What's the Difference Between @Component, @Repository & @Service Annotations in Spring
Java.Net.Connectexception: Connection Refused
How to Run Unix Shell Script from Java Code
Jtextfields on Top of Active Drawing on Jpanel, Threading Problems
Does a Lambda Expression Create an Object on the Heap Every Time It's Executed