Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I got a new computer and I'm trying to get Notepad++ to run how it did on my old one. I got the NPPExec plugin. When I click Execute, it brings up the commands I want to enter. My goal here is to have the code save, compile, and run in the console of Notepad++. Currently I have what I thought used to work on my old laptop.
cd $(CURRENT_DIRECTORY)
javac $(FILE_NAME)
java $(NAME_PART)
Whenever I try and execute it though, I get
Current directory: C:\Directory
javac HelloWorld.java
; about to start a child process: "javac HelloWorld.java"
CreateProcess() failed with error code 2:
The system cannot find the file specified.
java HelloWorld
; about to start a child process: "java HelloWorld"
CreateProcess() failed with error code 2:
The system cannot find the file specified.
I've tried it on files I used to have, and just a basic Hello World
class HelloWorld
{
Public static void main(String args[])
{
System.out.println("Hello World");
}
}
I don't get what the problem is, and would love if someone would be able to help.
Edit: I am using Windows
After checking here: https://beginnersbook.com/2013/05/first-java-program/ and seeing the Set Path section, I reinstalled Java, did the set path command, although the file path ended at \Java and did not have that whole JDK bit in it. I'm not sure if that's part of the issue and Java is not installed properly.
Edit 2: Tried to Find where I can install JDK, and everything sent me to Oracle's website. Is this needed?
Edit 3: Well, I tried just executing the javac command through command prompt and got
'javac' is not recognized as an internal or external command, operable program or batch file.
So I'm pretty sure it's the issue with JDK not being in the folder. I went to check my old laptop, and it didn't have JDK in the folder either. It gives the same error when using the javac command, but for some reason the java command works fine to execute the file. Do I really have to create an Oracle account just to get JDK? When I went to sign up it wanted my work phone number, so it definitely didn't seem like a free thing.
Edit 4: I tried following the Oracle documentation on installing a jdk. I did the download from there, but following that, I didn't see the file I needed. In the Java folder, there is now the jdk-16 folder. In the bin folder there, there are a number of .exe files, but I don't know if any of them are the ones I'm supposed to run. Now that I've installed it though, I'm still getting an error with javac command, but the java command will run files I'd previously compiled.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 13 days ago.
Improve this question
In my command prompt (on Windows 10), I can run javac with any java file just fine. But, when I go to run the created class with "java [classname]" I get
Error: Could not find or load main class [class name]
Caused by: java.lang.ClassNotFoundException: [classname]
I used to be able to run just the command "java [classname]" and it ran AOK, but now it's not working and I need "java -cp . [classname]" instead. Why? Is there a way around this?
Here's a bit of a timeline when I started having trouble:
Had to isntall JUnit for my CS class, around where the issues started happening
Had to install some Java extensions with VS code.
The Java runtime shouldn't be impacted by installing JUnit or Java extensions in Visual Studio Code, however it's possible that any modifications to your classpath or environment variables contributed to the problem.
You can try telling the Java runtime to look for classes in the current directory by changing the CLASSPATH environment variable:
set CLASSPATH=.
I fixed it, in the style of Daniel's answer.
Turns out that when I installed JUnit, the instructions had me put CLASSPATH in my environment variables. Removing the CLASSPATH variable or changing it to "." let me run from my cmd again without specifying classpath, since I removed what was redirecting my classpath. Then all I had to do was close and reopen my terminal.
When I try to run a code snippet in Java Scrapbook, Eclipse cannot start the VM with the following error:
Unable to launch scrapbook VM
Exception occurred executing command
line.
Cannot run program "C:\Program
Files\Java\jdk-14\bin\javaw.exe" (in directory "C:\tmp"):
CreateProcess error=206, The filename or extension is too long
There was a bug report in Eclipse's Bugzilla, but it was closed without a satisfactory answer.
The other similar answers on SO have different causes:
Starting in directory with an unusual name
Starting in an Android project
I tried changing the working directory to C:\tmp so that any issues caused by directory structure are solved, but to no avail.
Environment: OpenJDK 14, Eclipse 2020-06, Maven project
The actual problem is that Windows cannot start a program whose command line is longer than about 32000 characters. This can happen if you have so many dependencies that the command line arguments reach the limit. This is why changing the directory to C:\tmp did not help, the size of this part is negligible when compared to all the dependencies on the command line.
There's a nice answer to a different question which contains some useful tips which can help out.
I initially worked around the issue by running the code snippet in a newly-created project, but this was only possible because I did not need any parts of the project I'm working on.
The real solution was to switch to Linux because pretty much all distributions have limits which exceed those of Windows by an order of magnitude or more.
I need to run a .jar in MATLAB, exactly as described in this original question I found in my search of Stack Overflow: how do I run a java .jar in Matlab I was having the same issues as the user here (got the same errors, did the same troubleshooting) The only difference is that I am running Java 1.8.0_144-b01 vs Java 1.8.0_121-b13 in the linked example.
However, when I tried the solution that worked in the above situation...
system ('java -jar C:\My\Java\Class\Path\To\MyJar.jar')
...I got the following message: "'java' is not recognized as an internal or external command,
operable program or batch file. "
The .jar is in my static path. The current directory is set to where the .jar file is located. Any help greatly appreciated.
This question already has answers here:
javac is not recognized as an internal or external command, operable program or batch file [closed]
(6 answers)
Closed 6 years ago.
I'm trying to run a basic "Hello World" app from the command line on windows 10 using
javac MyFirstProgram.java
but i receive
'javac' is not recognised as an internal or external command, operable program or batch
naturally, the first thing i did was google the problem and many solutions were presented, tried a few but nothing worked, has anybody else experienced this?
Steps to fix this error in windows 10/8/7
1.Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and copy the address.
2.Go to Control Panel. Environment Variables and Insert the address at the beginning of var. Path followed by semicolon. i.e C:\Program Files\Java\jdk1.7.0_02\bin; . Do not delete the path existent, just click in and go to the left end and paste the line above. Do not try anything else, because you just need to link your code to "javac.exe" and you just need to locate it.
3.Close your command prompt and reopen it,and write the code for compile and execution.
You need to add the location of your JDK to your PATH variable, if you wish to call javac.exe without the path.
set PATH=%PATH%;C:\path\to\your\JDK\bin\dir
Then...
javac.exe MyFirstProgram.java
OR, you can simply call it via the full path to javac.exe from your JDK installation e.g.
C:\path\to\your\JDK\bin\javac.exe MyFirstProgram.java
I'm simply trying to open a JAR file on my Mac running 10.9.5.
But can't seem to get it open. I have tried litteraly everything, but I have this error code from console:
Class JavaLaunchHelper is implemented in both /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java and /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/./libjli.dylib. One of the two will be used. Which one is undefined.
One guy said that there are conflict between two files. I just want to open it, have not made anything. Developer wont get back to me.
Can some on you guys check out the jar file?
Thanks in advance! Need help :(
OK i had the same problem weeks ago.
Open terminale and check your default java version.
java -version
after this check your java path
which java
if you want to run your program with your java installation edit your PATHvariable.
PATH=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java:$PATH
export $PATH
then you can run your program for terminal
java -jar ....