I'm trying to run a complied class with the command:java SocketTest in current directory.
But something wrong:
Exception in thread "main"
java.lang.NoClassDefFoundError:SocketTest(wrong
name:socket/SocketTest)...
here is my classpath AND path configration in windows XP:
JAVA_HOME:
C:\Program Files\Java\jdk1.7.0_25\
classpath:
.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
path:
%JAVA_HOME%\jre\bin;C:\Program Files\Java\jdk1.7.0_25\bin;C:\Ruby187\bin;H:\Program Files\ARM\ADSv1_2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%JAVA_HOME%\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN
I think the .; has been carefully written,so I'm not sure what's wrong with the java command. Someone help,please!
The error message has pointed out you need to put the your class to the corrected package socket. So you need to create folder with name socket and then put your SocketTest.class to this folder and run the following command (under the parent folder of socket):
java socket.SocketTest
Related
I am using NCache NodeJS client package and writing tests by calling NCache API's. Package has dependency of Java. After I installed and used that package to write simple test. Test execution failed with module not Found error:
Error Message
Messgae:
The specified module could not be found.
\\D:\GitHome\Test\node_modules\java\build\Release\nodejavabridge_bindings.node
at Runtime._loadModule (node_modules/jest-runtime/build/index.js:893:29)
at Object.<anonymous> (node_modules/java/lib/nodeJavaBridge.js:21:16)
File in above mentioned directory exits.
Note: When I used that package in simple index.js file it worked fine as expected but unable to run with jest.
No major configuration done for jest in package.json file.
Java jdk-11.0.6 installed on box and JAVA_HOME is set.
Package.json
test.specs.js
Unable to identify the exact reason of failure therefore stuck on how to resolve it.
Environment:
OS: Windows
node: 14.15.3
jest: 26.6.3
C:\Program Files\OpenJDK\jdk-16.0.1\bin\server needs to be in your path. On windows can Edit the system environment > Environment Variables... > System variables and add C:\Program Files\OpenJDK\jdk-16.0.1\bin\server
Other option is to add it to your test runner. For example in WebStorm edit the Run Configurations and add Environment variables PATH=C:\Program Files\OpenJDK\jdk-16.0.1\bin\server
Below approach I tried to run and compil
for compile:
javac -cp "C:\Program Files\Java\jdk1.7.0_45\bin;D:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc.jar" OracleTest.java
for execution:
java -cp "C:\Program Files\Java\jdk1.7.0_45\bin;D:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc.jar;." OracleTest
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
The JDBC drivers from oracle usually include a (Java) version number in the name like ojdbc14.jar or ojdbc7.jar. I do not have Oracle installed here, so please check the correct name in your directory D:\oracle\product\10.2.0\db_1\jdbc\lib\.
You can test my DBTester program I wrote a long time ago from here. After downloading the jar - eventually you need to rename DBTester.jar.zip to DBTester.jar - just execute it in the directory you saved the jar:
java -cp "DBTester.jar;D:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc7.jar" cfh.dbtester.Main -d
(assuming the ojdbc7.jar is the driver file and using Java 7 or later)
This should print a summary for some drivers, including the Oracle one, like
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
...
java.lang.ClassNotFoundException: com.ingres.jdbc.IngresDriver
oracle.jdbc.driver.OracleDriver OK
the last line is telling me that I have the OracleDriver available.
Note: DBTester.jar creates a file named dbtester.log with its results.
Can you try with this?
"%JAVA_HOME%\bin\java.exe" -cp "%~dp0\ojdbc.jar" OracleTest.java
Important thing to note here is to have the JAR file at the same location as of your JAVA class that you want to compile/execute and accordingly change the command.
Hope this helps!
I am running java 1.8.0_65 on Windows 7.
I create a JAR and run it with the following command:
java -jar printxml.jar
And get this error:
Error: Could not find or load main class printxml.PrintXml
Here is my command to create the JAR:
jar cmfev manifest.txt printxml.jar printxml.PrintXml #filelist.txt
Contents of file "manifest.txt":
Class-Path: C:\Users\Me\SQLSER~1\JDBC\jtds-1.3.1.jar
I checked whether printxml.PrintXml class is in the JAR via this command:
jar tvf printxml.jar printxml/PrintXml.class
The command succeeded, i.e. PrintXml class is in the JAR.
I then checked if the PrintXml class in the JAR has a "main" method via this command:
javap -classpath printxml.jar -public printxml.PrintXml
The command succeeded and its output included...
public static void main(java.lang.String[]);
Searching the Internet, I found only the obvious answers, like:
Your classpath is wrong.
Your class doesn't have a "main" method.
Can someone please tell me how to resolve this problem?
Thanks,
Avi.
As Homer Simpson would say: D'OH
The value of the Class-Path entry in file "manifest.txt" is wrong!
It needs to be a URL!
So I changed it to:
file:/C:/Users/Me/SQLSER~1/JDBC/jtds-1.3.1.jar
Hey presto! No more error message. Now it runs!
Thanks to all who helped. ;-)
I am getting this error if I add new component to my frame if I remove it then it works.
I done this troubleshooting
(1)deleting index folder and restart computer and netbeans
(2)increased heap size in conf file
(3)set environment variable in windows system as
:-User variable name = CLASSPATH
:-variable value = C:\Program Files (x86)\Java\jdk1.8.0_40\bin;C:\Program Files (x86)\Java\jre1.8.0_40\bin;.
:-System variable name :-Path
:-System Variable value:-C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Java\jdk1.8.0_40\bin;C:\Program Files (x86)\Java\jre1.8.0_40\bin
but the problem persists
if i add new component(radiobutton,label,scrollpane) it gives me this error:
you can try Clean and build your project, if it doesn't work, you can check the posts from
Netbeans - Error: Could not find or load main class ,
Error: Could not find or load main class (netbeans and java)
or
What does "Could not find or load main class" mean?
With Java 11 you can start a class from the terminal with
java classname.java
I'm trying to create my custom C# minecraft launcher but I have this error.
I created a launcher.bat file first in order to solve this problem quicker.
I have this code to start minecraft:
java
-Djava.library.path=C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.1\
-cp
C:\Users\Davide\AppData\Roaming\.minecraft\versions\1.7.10\1.7.10.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\java3d\vecmath\1.3.1\vecmath-1.3.1.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\net\sf\trove4j\trove4j\3.0.3\trove4j-3.0.3.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\io\netty\netty-all\4.0.10.Final\netty-all-4.0.10.Final.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\google\guava\guava\15.0\guava-15.0.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\commons-io\commons-io\2.4\commons-io-2.4.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\google\code\gson\gson\2.2.4\gson-2.2.4.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\com\mojang\authlib\1.5.21\authlib-1.5.21.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-api\2.0-beta9\log4j-api-2.0-beta9.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-core\2.0-beta9\log4j-core-2.0-beta9.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl\2.9.1\lwjgl-2.9.1.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.1\lwjgl_util-2.9.1.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.1\lwjgl-platform-2.9.1-natives-windows.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\net\java\jinput\jinput-platform\2.0.5\jinput-platform-2.0.5-natives-windows.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch\5.16\twitch-5.16.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch-platform\5.16\twitch-platform-5.16-natives-windows-64.jar;
C:\Users\Davide\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch-external-platform\4.5\twitch-external-platform-4.5-natives-windows-64.jar;
net.minecraft.client.main.Main
--username MYUSERNAME
--accessToken MYACCESSTOKEN
--version 1.7.10
--gameDir C:\Users\Davide\AppData\Roaming\.minecraft
--assetsDir C:\Users\Davide\AppData\Roaming\.minecraft\assets
--userProperties {}
--uuid MYUUID
But when i start it says Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path.
I found on the internet that's a problem of this line
-Djava.library.path=C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.1\
But I double checked the path is correct.
Thank you in advance.
EDIT
I solved this problem easily taking out this from the arguments:
-Djava.library.path=C:\Users\Davide\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.1\
And putting al the DLL's in the local folder, i can't still access them with the full path though
Ok i found the answer. I had to use the local path and not the absolute one