81

I am trying to run a .jar file that was created successfully in Netbeans and I am receiving the following error:

Error occurred during initialization of VM java.lang.Error: Properties init: Could not determine current working directory. at java.lang.System.initProperties(Native Method) at java.lang.System.initializeSystemClass(System.java:1070)

The command that I type to run the .jar is

java -jar "/path to the dist forlder/EOPPrototype.jar" 

My classpath is as follows:

CLASSPATH=/opt/netbeans-7.1.2/ide/modules/ext/mysql-connector-java-5.1.13- bin.jar:/h/USERS/local/pagola/NetBeansProjects/mylib/dist/mylib.jar:/h/USERS/local/pagola/NetBeansProjects/EOPPrototype/build/classes:. 

What am i missing?

1
  • Properties init: Could not determine current working directory. happens in some JVM17 when there is no such directory and a user is running from inside of it. Ironically after doing a step back cd .. a user appears in .Trash directory there and if merely to repeat the last command in log sometimes there is one such as the application is started by user_name in /Users/user_name/.Trash. Commented Nov 13, 2024 at 16:18

12 Answers 12

219

I saw the same error when I was trying to call java -version inside a directory, which I already had deleted from another terminal session. Of course in that case java could not determine the current working directory, simply because it didn't exist.

Sign up to request clarification or add additional context in comments.

6 Comments

this happened to me when i issued a command in the maven target directory that: was present, then i did a clean and build (clean install), then issued the same command. Even though the path was still valid, the specific directory entry i issued the command in first was not there (OS X) doing a cd ../target fixed my issue
..aaand how does one fix this?
I had the same problem calling java -v from /Applications/NetBeans-8.1beta/glassfish-4.1/glassfish/domains/domain1/generated. That 'generated' folder is a regenerated cache folder from NetBeans. When I cd-ed out then back to the same /generated the problem did not happen and java -version worked giving java version "1.8.0_60"
Simply get out and enter again in the directory
What a weird issue. Happened to me tonight and this was exactly what it was. I was inside <project>/target/classes in a terminal, ran a mvn clean compile, and then tried re-running the java command from the first terminal. I guess the Maven command deleting and re-creating the directory screwed the old terminal up. Using cd to go back to the project root and then back into the classes directory fixed it for me.
|
38

Solution: cd to another directory and run that command again, that works for me.

See explanation here: https://bugs.openjdk.java.net/browse/JDK-8186434

1 Comment

It happens when a folder you're in was removed
14

In Fedora 21, I tried calling the "java -version" after an uninstall and it gave the above error. Close all the terminals and open them again and try.

Should work.

3 Comments

Same for me, with ubuntu
Same for me also, with LinuxMint 18.3.
Same for me with Debian in WSL
4

I was getting the same error message, but I'm not sure if it was for the same reason as I don't use Netbeans. I use my terminal and compile with ant.

I cd'd to a directory to run a javafile.class file. The file I want to run is part of a bigger package. The directory structure of the package looked something like this: a/b/c/javafile.class. The a, b, and c directories are all part of a larger package.

To run my javafile.class, I cd'd into a and ran the file from there: java b/c/javafile. After I made some changes and recompiled with my ant script, the directory I was in had been deleted and remade by ant. So, when I ran javafile.class again, I got the error you're getting.

I fixed my problem by cding out of the directories that are deleted and remade by ant and then running my javafile.class again.

1 Comment

Thanks. Navigating out of a high-up directory and down to a lower one, then re-running my command fixed the issue for me too.
4

maybe you did not config java environment on your workstation correctly

the following configurations were what I did in my mac

vi ~/.bash_profile 

and add those in it

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home PATH=$JAVA_HOME/bin:$PATH:. CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. export JAVA_HOME export PATH export CLASSPATH 

replace

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home 

with your jdk version and then run

source ~/.bash_profile 

to use these config immediately then you can check by

java -version 

Comments

3

I got the same error -

Error occurred during initialization of VM

java.lang.Error: Properties init: Could not determine current working directory.

by just doing 'java -version' (you would think it wouldn't need to bring up a virtual machine just to answer a simple question like 'what version are you?')

A higher up element (that between the slashes) of the directory path of the pwd had spaces in it. When I made the current working directory one which from / downward didn't have any spaces the 'java -version' command got a proper response.

I'm concluding they didn't account for directories with spaces when they programmed it. But that was version 1.7. I've now loaded version 8 so hopefully it has been corrected.

1 Comment

I had the same problem calling java -v from /Applications/NetBeans-8.1beta/glassfish-4.1/glassfish/domains/domain1/generated (has dots and hyphens, not spaces, but they might also cause problems [NO, see EDIT]). Then I got OK java version "1.8.0_60" (seems is still a problem with Java8. EDIT: it was because that 'generated' folder is a regenerated cache folder from NetBeans. When I cd-ed out then back to the same /generated it did not happen. asmaier (below) is right.
3

I got this error on Mac OS X and this is a genuine error since the directory has vanished. The directory I was when I am executing the commands is <PROJECT DIR>\target.

The problem was I opened two terminals in the other terminal I ran mvn clean install and the target directory from PROJECT DIR got deleted and recreated.

My old terminal from where I was executing Java commands is not in a valid directory.

The file descriptor is invalid since the directory got deleted by Maven.

When I moved back to the parent directory and the changed back to the target directory, the java command started working correctly as expected.

Comments

2

Under CentOS, rhel, SL or SLC? Not an issue under debian/ubuntu.

I found you need to logout of the shell you are using and log back in. The environment is not set up initially correctly for the current shell. After login I see that: java -version will work.

Also ensure that /etc/alternatives/java actually points to something reasonable like:

ls -lisa /etc/alternatives/java 72645 0 lrwxrwxrwx. 1 root root 46 May 27 11:29 /etc/alternatives/java -> /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java 

Comments

0

Just now, i got the same error. because i use java to setreuid/setregid to apache:apache, when i change back to root:root, i changed gid before uid, the real result is root:apache. everything going wrong, such as the error say "java.lang.Error: Properties init: Could not determine current working directory. "

you can check it.

Comments

0

I was having this error in my mac, when I start tomcat from my eclipse. After setting JAVA_HOME and restarting the eclipse, the error is fixed.

Comments

0

You have to install default-jdk first ! sudo apt install default-jdk only version 11 does not set all the environment correctly in place of : sudo apt install openjdk-11-jdk

Comments

-1

You may get this error if you issue "java -version" or other java command from a read-only directory. For example using openjdk 8 on centos (as non-root user):

cd /usr/bin java -version 

Error occurred during initialization of VM java.lang.Error: Properties init: Could not determine current working directory.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.