JavaFX 11: "JavaFX runtime components are missing" - java

I'm trying to run sample JavaFX code (taken from the 5th edition of Java Illuminated) under JavaFX 11 and Java 11, using jGRASP 2 under Windows 10.
I've read through the "Getting Started with JavaFX" guide (https://openjfx.io/openjfx-docs/) extensively, and while I've made some progress, I'm stuck.
I've downloaded the latest ZIP file, unpacked it, and updated the CLASSPATH to include a path to the jar files needed to compile. I can successfully compile the file. However, when I try to run, I get the following error message:
Error: JavaFX runtime components are missing, and are required to run this application
The "Getting Started" guide says that this can be fixed by adding the following options to the runtime call:
--module-path "[path]\lib" --add-modules=javafx.controls,javafx.fxml
I've added the options, but I'm still getting the error message.
Previous StackOverflow articles usually end with the option setting above; alas, I can't figure out what else to do.

As a first time user, I've managed to make it work, but it was not straightforward to me.
I guess there are no many people familiarized with this IDE, so I'm going to post the steps I followed, as a basic tutorial:
Download and install jGRASP version 2.0.5_05 Beta.
Since I have a few JDKs installed, it selected by default JDK 10.0.2, so my first step was to find a way to work with JDK 11. That can be done in Settings -> jGrasp Startup Settings, where I can set the path for my java executable:
Then I restarted jGrasp. You can verify which JDK the IDE is using in Tools -> System Info -> Java Version.
Open HelloFX sample class. I've started with the most basic sample from the OpenJFX docs. The code can be found here.
Build -> compile, as expected, will throw a bunch of errors given that JavaFX is no longer part of the JDK:
Following the OpenJFX docs, we need to download the JavaFX SDK from here, and then add the library to the classpath. Go to Settings -> PATH/CLASSPATH -> Workspace, press New, and add, one by one, the different JavaFX jars from the downloaded SDK/lib folder (at least javafx-base.jar, javafx-graphics.jar and javafx-controls.jar).
Build -> compile should work now.
Next step: Build -> Run. This fails:
----jGRASP exec: java HelloFX
Error: JavaFX runtime components are missing, and are required to run this application
----jGRASP wedge: exit code for process is 1.
----jGRASP: operation complete.
That was expected. According to the docs, we need to set the module-path and add-modules arguments.
First attempt: use Run arguments. After setting:
--module-path /Users/<user>/Downloads/javafx-sdk-11.0.2/lib --add-modules javafx.controls
running again failed with the exact same error message as above, but with one difference in the console log:
----jGRASP exec: java HelloFX --module-path /Users/<user>/Downloads/javafx-sdk-11.0.2/lib --add-modules javafx.controls
What's wrong with that!? Well... if you try that on command line, it will fail as well, because the order of arguments is wrong, the vm arguments should go before the class name.
In conclusion: Run arguments are not VM arguments!
Second attempt: In order to provide the VM arguments, the option I found was to edit Settings -> Compiler settings -> Workspace. By default, it is using jdk (integrated debugger) - generic. You can view it and see that for Run it uses:
java %S -ea %S %<FLAGS2> %<MAIN_CLASS> %<ARGS>
So instead of ARGS we need to find a way to set FLAGS2.
Luckily, next to the Environment tab, there is a Flags/Args tab, and there we can set our vm arguments in FLAGS2:
--module-path /Users/<user>/Downloads/javafx-sdk-11.0.2/lib --add-modules javafx.controls
Apply, close the dialog, and Build -> Run the class, now it will work!
If you see the console log, it contains exactly the command you would use when running on command line:
----jGRASP exec: java --module-path /Users/<user>/Downloads/javafx-sdk-11.0.2/lib --add-modules javafx.controls HelloFX
----jGRASP: operation complete.
I guess the next step will be running a more complex project...

Try simply creating a launcher with only a main Method. It could look something like this:
package application;
import javafx.application.Application;
public class MyAppLauncher {
public static void main(final String[] args) {
Application.launch(MyApp.class, args);
}
}
(you can leave the old main Method unused in your App for the time-being)
This worked for me with JDK 13 & JavaFX 13 & Eclipse 2019-12 under Ubuntu.
(I created the Project using "new/Maven Project/Simple Project" and then just added JavaFX, Logging & other stuff as dependencies in pom.xml, which all landed on the Classpath. Only the JDK was on the Modulepath)
No need to bother about Java Modules.
If that works, you can take time to learn about Java Modularisation another day...
...and remember to vote for this Answer. :-)

Related

Java Compiling issue when first using vscode

I have been using vmware to log into the lab machines at my uni. I just started using vscode on my pc. I installed latest jdk 16.0 and i installed the java extension pack from vscode. But it still wont let me run or compile my program
I keep getting this error, thought it was an issue about the paths after a little bit of research so i made the java:home path to where jdk folder is in my c drive and i still get this error:
c:; cd 'c:\Users\Aaron Mark\Desktop\UNI\FinalAssignment'; & 'c:\Users\Aaron Mark\.vscode\extensions\vscjava.vscode-java-debug-0.34.0\scripts\launcher.bat' 'C:\Program Files\Java\jdk-16.0.1\bin\java.exe' '--enable-preview' '-XX:+ShowCodeDetailsInExceptionMessages' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\Aaron Mark\AppData\Roaming\Code\User\workspaceStorage\2bfa7b3e373492b1fc42e07c42d17320\redhat.java\jdt_ws\FinalAssignment_fe08a03d\bin' 'QuestionOnePartA
How do i fix this class not found error?
I think you point to the blue sentences displayed before the real output, actually they are not errors but execution scripts, which shows the necessary building and compiling commands to get the output:
If you don't want to see these scripts but pure output, create a launch.json and add "console": "externalTerminal", in configurations. Run without debugging(Ctrl+F5) can open a new external Terminal and no execution scripts shown:
This is not error.
IDE is printing all the program being used for compiling and running the code.
'-cp' : this is your classpath. You can add more external library using it.

Run Groovy at the CLI with Java 9+ module settings

OS: Linux Mint 18.3
The combo I want to run is: Groovy 3.0.+ (app and testing code) & Java 11+ & JavaFX 11+
Having had a little help (see comments here) I can now do this using a gradle.build file (including outputting an executable using the Gradle "installDist" task from the application plugin).
I've also managed to do this from a non-Gradle Groovy-enabled project in IntelliJ, by configuring the classpath and module-path appropriately.
My file javaFXTest.groovy looks like this (NB this is the Groovy script which I get IntelliJ to run):
package core
import javafx.application.Application
import javafx.fxml.FXMLLoader
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.stage.Stage
Application.launch( GrApp, args)
class GrApp extends Application {
#Override
void start(Stage primaryStage) {
Parent root = FXMLLoader.load(getClass().getResource("/dialog1.fxml"))
primaryStage.title = "Hello World"
primaryStage.scene = new Scene(root, 1200, 800)
primaryStage.show()
}
}
I'm just wondering, for the sake of interest, how this is actually done in terms of a CLI groovy command. I thought it might be something like this:
groovy -cp .:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/* --module-path /home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml core/javaFXTest.groovy
oops:
Caught: java.io.FileNotFoundException: /home/mike/IdeaProjects/JavaFXExp2/AppTest/src/main/groovy/--module-path (/home/mike/IdeaProjects/JavaFXExp2/AppTest/src/main/groovy/--module-path)
... it clearly doesn't recognise --module-path as a configurable option, confirmed by going groovy --help. I searched on this and found nothing. And yet IntelliJ manages to run this script: the --module-path and --add-modules options are added as VM options to the run configuration. Anyone know how this might be done as a CLI command?
On the suggestion by cfrick I found the answer: Intellij does indeed show the whole command in the "Run" view (if you click the '...'):
Turns out this is a giant Java command with all sorts of stuff beyond my understanding, and inclusion of many Groovy .jars for example. I show it in its magnificence for anyone interested: I've split up into lines to show the options a bit more clearly.
/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java
-Dgroovy.home=/home/mike/.sdkman/candidates/groovy/3.0.2
-Dgroovy.starter.conf=/home/mike/.sdkman/candidates/groovy/3.0.2/conf/groovy-starter.conf
-javaagent:/home/mike/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/201.6073.9/lib/idea_rt.jar=41350:/home/mike/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/201.6073.9/bin
-Dfile.encoding=UTF-8
-classpath /home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-3.0.2.jar org.codehaus.groovy.tools.GroovyStarter
--conf /home/mike/.sdkman/candidates/groovy/3.0.2/conf/groovy-starter.conf
--main groovy.ui.GroovyMain
--classpath .:/home/mike/IdeaProjects/JavaFXExp2/out/production/AppTest:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-test-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-yaml-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/junit-platform-launcher-1.6.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/junit-jupiter-api-5.6.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/junit-jupiter-engine-5.6.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-templates-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-groovysh-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jsp-api-2.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/ant-1.10.7.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jackson-dataformat-yaml-2.10.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/javaparser-core-3.15.13.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-json-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/ant-launcher-1.10.7.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-xml-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-testng-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-jmx-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/commons-logging-1.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-dateutil-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/junit-4.13.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/hamcrest-core-1.3.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/xstream-1.4.11.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/ivy-2.5.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-servlet-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/gpars-1.2.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jcommander-1.72.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jsr166y-1.7.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/ant-antlr-1.10.7.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/multiverse-core-0.7.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-jsr223-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-sql-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-groovydoc-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/bsf-2.4.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/org.abego.treelayout.core-1.0.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jackson-core-2.10.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/ST4-4.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-console-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jackson-annotations-2.10.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jansi-1.18.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-datetime-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-astbuilder-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-jaxb-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-ant-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-test-junit5-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-swing-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/qdox-1.12.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-cli-picocli-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/javax.servlet-api-3.0.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-cli-commons-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-macro-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-nio-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/junit-platform-engine-1.6.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/junit-platform-commons-1.6.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/testng-6.14.3.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jackson-databind-2.10.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/ant-junit-1.10.7.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/opentest4j-1.2.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-bsf-3.0.2.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/commons-cli-1.4.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/snakeyaml-1.24.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/jline-2.14.6.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/groovy-docgenerator-3.0.2.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/src.zip:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx-swt.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx.web.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx.base.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx.fxml.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx.media.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx.swing.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx.controls.jar:/home/mike/.java/JavaFX/javafx-sdk-11.0.2/lib/javafx.graphics.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/extras-jaxb/jaxb-api-2.3.0.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/extras-jaxb/activation-1.1.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/extras-jaxb/jaxb-core-2.3.0.1.jar:/home/mike/.sdkman/candidates/groovy/3.0.2/lib/extras-jaxb/jaxb-impl-2.3.0.1.jar
--encoding=UTF-8
/home/mike/IdeaProjects/JavaFXExp2/AppTest/src/main/groovy/core/javaFXTest.groovy
I hazard a guess that the first -classpath option (with the single dash) is presumably setting that for the "javaagent"... or could it be for the "Groovy starter"...?
This at least solves the conundrum: I had understood that Groovy (even Groovy 3) can't handle Java 9+ modules. So it would make sense that this must be a Java command. Maybe running with a groovy commmand will become possible with Groovy 4, which as I understand it will (hopefully) be able to be able to handle these modules.

Issue running tensorflow with java

I am having some issues running tensorflow with java. I am using CUDA 8 with CuDNN 6.
I tried following the quickstart instructions located here: https://www.tensorflow.org/install/install_java and get the following error message when I attempt to run the example java program:
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot find TensorFlow native library for OS: linux, architecture: x86_64. See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java/README.md for possible solutions (such as building the library from source). Additional information on attempts to find the native library can be obtained by adding org.tensorflow.NativeLibrary.DEBUG=1 to the system properties of the JVM.
at org.tensorflow.NativeLibrary.load(NativeLibrary.java:75)
at org.tensorflow.TensorFlow.init(TensorFlow.java:66)
at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:70)
at org.tensorflow.Graph.<clinit>(Graph.java:258)
at HelloTF.main(HelloTF.java:8)
The jni directory contains the following:
libtensorflow_framework.so
libtensorflow_jni.so
LICENSE
I then tried installing the binaries from source as suggested here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/README.md
This is the output from setting: org.tensorflow.NativeLibrary.DEBUG=1
org.tensorflow.NativeLibrary: tryLoadLibraryFailed: /path/to/jni/libtensorflow_jni.so: libcublas.so.8.0: cannot open shared object file: No such file or directory
org.tensorflow.NativeLibrary: jniResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_jni.so
org.tensorflow.NativeLibrary: frameworkResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_framework.so
But I still get the same error message when I try and run the example Java program.
What am I doing wrong??
Any help would be greatly appreciated!
The error
Cannot find TensorFlow native library for OS: linux, architecture: x86_64.
is clearly stating that the library is not visible to your software.
To make it available to the Java class, try doing like that (in the same shell obviously):
export LD_LIBRARY_PATH=/the/absolute/path/to/your/library
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
also ensure you're running the java command from the same directory which contains the /jni directory.
For those landing here and facing the same issue.
You are probably trying to run your program from eclipse. Then, you have to go to Run configurations > Arguments and pass this arguments:
Program arguments -> models/
images/example-400x288.jpg
VM Arguments -> -Djava.library.path=./jni
like in this screenshot:
When people (like myself) come from python to java world, everything is strange! here is how I solved my problem regarding all linking errors:
I assumed you already have simple hello Tensorflow project, explained here
Download and copy tensorflow JNI files to :/usr/lib/tensorflow
Download and copy desired version of tensorflow Lib jar file to: /usr/lib/tensorflow
Compile with java
Compile java file
javac -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar HelloTensorFlow.java
run java file:
java -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar:. -Djava.library.path=/usr/lib/tensorflow/ HelloTensorFlow
use MAVEN
First we should export LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/tensorflow
Then run maven build command:
mvn -q compile exec:java
I hope it helps you

Unrecognized option: - Could not create the Java virtual machine

I am trying to run my .jar file on a linux server.
These are the commands I'm running:
JAVA_HOME=/app/local/opt/jdk/packages/jdk1.6.0_30/
export PATH=$JAVA_HOME/bin:$PATH
cd folder
nohup java -jar program.jar &
When ran on Friday, this was working perfectly. However, today I am getting:
Unrecognised option: - Could not create the Java virtual machine.
In my nohup.out
If I run java -v after setting the path I get the same problem. Can anyone suggest anything? Really confused about this.
Thanks for any help on this.
Usually, when we get this kind of exception ("Unrecognised option" which causes the "Could not create the Java virtual machine"), the JVM displays the unrecognized option, like this:
Unrecognised option: -[option details] Could not create the Java virtual machine.
the fact that you have no details makes it seem as though you just have a space (" ") in your command.
Take a look again to make sure.
I've got this failure running maven on Win10 where the pom.xml is located in a folder named something like C:\dir\OneDrive - bar\workspace\project.
Moving the project to a different folder solved it.
First of all, there is no -v option on the java command.
(Reference: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html ... Java 6 version ... 'cos that is what you are using. Try java -help for the short list of options.)
So it is expected for java -v to fail.
As an experiment I tried this (with an OpenJDK Java 8 JDK on Fedora 22):
$ java -foop
Unrecognized option: -foop
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
$
As you can see, the "unrecognized option" message tells me what option it doesn't understand. Looking at the message in your question, we see that it is saying it is "-". That doesn't appear to match the command line in your question, but on the other hand the command line in your question does not have any invalid options.
Another possibility, I guess, is that you have a shell alias called java. That would take precedence over any commands on the shell's command path.
The other thing is that you are running an ancient version of Java. Java 6 has passed end-of-life, and the last publicly released version is update 45. You are running update 30 which was released in December 2011. There have been LOTS of security patches since then. I'd recommend upgrading to Java 8 ... and making sure that you keep it up to date.
for java 8 run 'java -version'
for java 9 or 9+ run 'java --version'
Had the same issue under Linux/Ubuntu 20.04.
I created a bash to run my jar and used some variables in the file
# This line below shows the error
$JAVA_PATH "-jar $JVM_ARGS $JAR_PATH"
# This line below runs without issue
$JAVA_PATH "-jar" $JVM_ARGS $JAR_PATH $SB_ARGS
I don't know why it works after using double quotes for the "-jar" option only, I think it's something to do with UNIX systems.

java runs in eclipse but won't run in command prompt

Just today I noticed that I can run java in eclipse with no problems but when I try to run it in the command prompt, I get "cannot find or load main class." The command prompt actually compiles all right, and it outputs a .class file, but then it displays the error msg when trying to execute. (Also, I was able to run java in the cmd a couple weeks ago.)
/* work area for practice
*
*/
package Scrap;
public class experimentational {
public static void main (String [] args) {
System.out.println("welcome to java!");
}
}
Found the answer: (i'm using different code but it is still relevant to this problem)
java -cp . hiThere
output: "Hi there"
I know this is classpath but don't know why it works or what the period does for it. Anyone have an idea?
Use:
javac Scrap/experimentational.java
followed by:
java Scrap.experimentational
try java -cp . [your main class].
Did you install a JDK on the machine outside of Eclipse? If you did, then make sure you set your path variables correctly. Open a command prompt (assuming windows) and type java -version
If the JDK was installed properly and path variables were set properly it should tell you the version of Java that was installed. If it tells you that 'java' is not recognized as a command that you do not have a JDK installed, or it was not installed properly.
The reason your program runs in Eclipse is that Eclipse for Java has its own internal JDK and JVM.
Your other option is to set up your path variables to point to Eclispe's internal JDK.
If you were able to run it from a command prompt previously then most likely your class path was altered. Is this a machine at work? Some companies have SMS tasks that come through periodically and restore default system settings (including path variables) to corporate defaults.
Maybe java and javac isn't in your OS path.
If you are using Microsoft Windows in cmd type path and then enter.
If jdk or jre isn't in path you need to put them to it
I had a similar issue when I copy pasted code into an editor. I removed the package declaration on line 1 and it ran then. So I'd investigate above comments on packages, after trying first to remove the package line.

Categories