Not sure what the issue is here but javac is not recognized when I try to compile a java file. I am assuming I need a special plugin for this or I am required to use apache ANT but not too sure.
cd src
javac HelloWorld.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
java HelloWorld
Error: Could not find or load main class HelloWorld
In Jenkins goto Manage Jenkins -> Configure System , scroll down to JDK installations and click the ADD JDK button.
I recommend trying the Install Automatically option, and let it install a fresh copy and give it a name you can recognize in project setting like jdk8_update51, and agree to the license.
In each project check that the JDK Setting is the correct version.
In windows batch command text box, you may want to add
echo "PATH is:"
echo %PATH%
echo "JAVA_HOME is:"
echo %JAVA_HOME%
javac -version
If this fails as above, try :
eg.
set PATH="C:\Program Files\Java\jdk1.8.0_31\bin"
javac -version
should print the following in Console Output:
javac 1.8.0_31
Note: "C:\Program Files\Java\jdk1.8.0_31\bin" should have the file javac.exe in it.
For Resolving this issue Go to :
Jenkins --> Manage Jenkins --> Global tool configuration.
You can add the full path JAVA_HOME there or click on "install automatically" for automatically downloading the Java.
I just tried this and issue is resolved now.
Thanks to Stackoverflow as well !!
Select "Manage Jenkins" and then "Configure System" on the Dashboard.
On the screen that opens, there is the "Environment variables" section. The tick next to it is marked. Then click the "Add" button. The «name» and «path» fields that appear after this marking are filled by entering the java-jdk path as in the image. Then click "Apply" and "Save" to complete the process.
That's all. I hope this will fix your problem. :)
**This solution can use for all similar command errors for python,maven, etc. **
Related
I downloaded a file for a game that requires Java to run.
When I downloaded the file it saved as a WinRAR file. So I right clicked the file and pressed open with Java Platform SE Binary (As that was the only Java add-on that came up). Then an Error Message came up which says:
Java Installation Not Completed.
Unable to install Java.
There are errors in the following switches:
("C:\Users\MyName\Desktop\The file name for The Game(2).jar").
Check that the commands are valid and try again.
But I have already Installed Java as well.
Has anyone got a fix they could recommend?
One of your files is corrupted. Simply download Jarfix and run it.
The Breakdown has an easy and helpful website to using Jarfix. Simply follow the instructions and download it in the link below:
https://thebreakdown.xyz/jarfix-to-repair-jar-files-on-your-pc/
This can be run by using Command prompt
Open Command prompt (in windows: Windows+R -> type 'cmd' then enter)
Follow the path specified to your specific folder(upto where your jar file exists)
for example: D:\projects\folder1\innerFolder>
now, java -jar filename.jar (then enter)
for example: D:\projects\folder1\innerFolder>java -jar filename.jar
Finally you can see your output
Note: Install java and also set path in environment variables
go try to open it via cmd by following:
press Win + "R" and type in "cmd" and press Enter
Then you type in the following:
java -jar C:\Users\MyName\Desktop\The file name for The Game(2).jar
if that dont work try to give more information (the full error, where do you get the error? As a Messagebox? Or as terminal output?)
It's very simple and easy!
go to your downloads folder
Click on the part where it says downloads and press backspace.
It should show the download icon and an empty bar.
In that area, type: cmd
then press enter
Once command prompt is open, type
java - jar (NAME OF FILE).jar
Example: java -jar Optifine-1.16.5.jar
then press enter. You're done!
I'd like to set Maven home properly, because it has caused me soo much problems before. Can somebody help me do it properly?
So I was greeted with this when I first tried to run my test program:
Then when I click preferences:
This is what terminal tells me my maven home:
So can somebody guide me? Any help would be much appreciated, thanks in advance!
Really alls you need to do is set:
MVN_HOME = <DIR TO MAVEN>
in your .bash_profile in your home directory. Here's a good SO to help you if you want to read it:
Maven Install on Mac OS X
Try to echo your MAVEN_HOME environment variable, check if it
matches the path printed by running "mvn -version". If not, set
MAVEN_HOME to this path.
Then restart your eclipse to see if eclipse can recognize it.
download maven zip file from http://maven.apache.org/download.cgi
extract zip file
click on Remote disk---> Show Enclosing Folders ---> Macointosh HD ---> Users
you'll see a folder whose icon looks like Home
this is your root folder or home folder
move your maven folder inside your home directory
now setting the env variable
open terminal
vi .bash_profile
i- for insert mode
export M2_HOME=/Users/kesharwanivikas/apache-maven-3.6.2
export PATH=$PATH:$M2_HOME/bin
Esc and ':wq'
close terminal and open a new one
type
mvn -version
you'll see that your maven is all set and ready !! Happy coding ✌🏻
I'm trying to get a working desktop launcher for Webstorm (applicable to any JetBrains product, however.) I've tried using the built-in menu "Add desktop launcher" in both Xubuntu and Lubuntu with no dice.
Running ./webstorm.sh from a terminal in the application's folder works fine.
If I add the option to the .desktop file to run in terminal I get an error message:
ERROR: cannot start WebStorm.
No JDK found. Please validate either WEBIDE_JDK, JDK_HOME or JAVA_HOME environment variable >points to valid JDK installation.
Press Enter to continue.
If I open a terminal and do javac -version I get a response, indicating my path is set correctly.
What gives? I am baffled as to what I'm doing wrong.
Set JAVA_HOME in your ~/.profile like this:
export JAVA_HOME=/usr/lib/jvm/java-7-oracle/
Then restart your system (or just X-Windows using sudo /etc/init.d/gdm restart).
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?
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.
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
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.
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.
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
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.
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.
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
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.
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.
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
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.
When I double click the jar file, the GUI program doesn't start by itself. Instead I have to open the Command prompt and then type java -jar abc.jar and only then it starts up. Why is that? What do I need to do to avoid this?
Is it that I have some problem with the default jar file opener? What should be the jar file opener?
if nothing happens, then don't you get any error message like could not find main class or something similar?
I would suggest check your jar file association. On command-line type:
ftype | find "jarfile"
Sometimes, even resetting it works, find out the absolute path of JRE and run the command:
ftype jarfile="C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
This would most probably solve your problem.
Maybe you would like to follow the instructions in this post: Running JAR file on Windows.
Just a minor note though. The exact syntax for me to work was in my Windows XP:
C:\Program Files\Java\j2re1.4.2_04\bin\javaw.exe -jar "%1" %
If your jar file opens successfully from the cmd line means its a correct jar and everything is in place. Now you have to associate the correct program with it.
Right click on the jar -> Open With -> Go to JRE/BIN/javaw.exe -> OK
Now all the jar files are associated with the correct program. Try now!
I had this same problem. In my case, I think it was because I was using Scanner(system.in) input.
By default, Windows opens .jar files with javaw.exe (thanks Johnydep), the version of java that runs without a terminal.
In my case, running javaw -jar myJar.jar didn't work either.
I ended up writing a tiny batch file that uses the regular java.exe: java -jar myJar.jar
Which operating system? You need to configure your default applications. In KDE this is under System Settings -> Default Applications. For Gnome, Mac, or Windows you will have to google to find where to set it.
On windows: right click on jar -> open with -> choose programm... -> select "Java (TM) Platform SE binary".
Optionally, check the "Always use the selected programm to open this kind of file".
Navigate to:
File->export->Java->Jar file->Next->use the tree to select the files you want to be included in your jar->Next->Next->
now i guess comes the part you have missed
at the bottom under "Main Class" click "Browse"->selcet the class you want to run when double click->press ok->finish.
should work now.
I couldn't find this answer anywhere and it solved my problem after i had same issue.
I had the same problem in Linux with a jar generated by Intellij, and I find that it's the problem of permission, the jar file's permission is
"-rw-rw-r--", you need to add the permission of execute:
$chmod +x xx.jar, and double click.
Maybe it is because your jar is not an executable jar due to which you cannot execute it directly by double clicking on it.