I am attempting to install Hibernate3 onto my linux server but I'm having a hard time figuring out what to do to get it to work. I have tried the following:
copy required jars into a folder and called the folder via "java -classpath etc." and got
java -classpath /home/mcmaster/javalibs/* -jar craftbukkit.jar
Error: Could not find or load main class .home.mcmaster.javalibs.dom4j-1.6.1.jar
load the java command while calling only the core hibernate which resulted in normal class not found error
on a whim installed to system java lib location with no affect
used apt-get to install libhibernate3-java with no change
I have attempted to export $CLASSPATH=~/javalibs which has all the required jars
I'm literally pulling my hair out as an intermediate java user trying to learn some more advanced things(to me).
Here's the error I'm getting when trying to call the Session Class:
Caused by: java.lang.ClassNotFoundException: org.hibernate.Session
Looks like you forgot the quotation marks. Try
java -classpath '.:/home/mcmaster/javalibs/*' -jar craftbukkit.jar (as seen on wikipedia).
EDIT: I am guessing that craftbukkit.jar is executable.
Related
I have a Java Code where I am able to run it on Intellij using custom configuration. The configuration has following attributes :-
module : java 8 (Oracle OpenJDK 1.8.0_321)
classpath : -cp XYZ.main()
main : com.ABC.XYZ.ManageTraffic
CLI arguements : server XYZ.yml
But when I try to run the jar that was build using gradle from terminal , it gives me Error , could not find or load main class com.ABC.XYZ.ManageTraffic
So far I have tried the following things looking at other solutions at Stackoverflow , still getting the same error
java -jar ques.jar
java -jar ques.jar com.ABC.XYZ.ManageTraffic
java -cp /build/libs/ques.jar com.ABC.XYZ.ManageTraffic
Just to cross check , I unzipped the creataed jar and found that com.ABC.XYZ.ManageTraffic class file is available there , still getting error. What could be the issue?
Run it from the IDE, and while it is running, try to get the command used by the IDE from the process list.
not sure what OS you are using but something like this should work on linux/mac:
ps -ef | grep java
After you have the command you can try to understand why its not working for you, or just use that command
Just want to add how I managed to run it. I created a new shaded jar file of the same application. refreshed its dependencies and now it works. I am yet to find out how creating a shaded jar instead of normal jar helped. Right now the only reason I could figure out is there may be version clashes with some dependencies but I wonder how it could throw could not found main class error.
Anyways , then I ran the file with the following command from terminal:
java -jar ./build/libs/ques-shaded.jar server XYZ.yml
Let me summarize the problem:
An exercise asked me to launch a java application using the Windows 10 Command Line.
It taught me on a video how to add the IntelliJ path to the Environment Variables, so that, whenever I typed java Main I would get my Main.java/class application back.
The first problem that I had stumbled upon was that, instead of using java Main, I'd have to type java Main.java. I thought that it was due to a recent build for the JDK (v14.02), so I let that one pass.
The second problem that I had encountered was that, when the exercise asked me to launch an application using the package directories, the command line would return the following error: Error: Could not find or load main class com.pluralsight.organized.Main. Caused by: java.lang.ClassNotFoundException: com.pluralsight.organized.Main.
Revert whatever damage you've done to the system.
Install the Oracle JDK.
Put the Oracle JDK bin folder on your PATH variable.
Compile your code using javac Main.java
Run your compiled code using java Main
for the ones in the packages, you need to be at the package root, or have a class path to it. For example, let's consider a class com.example.Main
The folder structure should be:
D:/SomePath/com/example/Main.class
Then you need to be at D:/SomePath/ to execute java com.example.Main.
Alternatively, you could be anywhere else and execute java -cp D:/SomePath com.example.Main.
So, I have removed openjdk from my new Ubuntu system and have installed Oracle JDK 8 and Eclipse from their respective websites. I can run a program from Eclipse, however I cannot run it from the command line. I am also not used to using Eclipse (I use NetBeans for my Java class in college.) I noticed that there is no build button in Eclipse. With all of that being said, here is my command line code:
wil#wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ ls
test.class test.java
wil#wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ java wiltest.test.java
Error: Could not find or load main class wiltest.test.java
wil#wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ java wiltest.testError: Could not find or load main class wiltest.test
wil#wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$ java test
Error: Could not find or load main class test
wil#wil-Aspire-E5-521:~/eclipse-workspace/wiltest/src/wiltest$
You need to add the -classpath . command line option.
You can learn more about classpaths here
I believe the command java -classpath . test might work, but it really depends on a number of items that are better explained in the link above.
I actually answered part of my question myself. (For anybody wondering, the classpath is set to be in present working directory by default.) Anyways, I was running java wiltest.test from src and not bin. However, I ran from binary file and it worked. BUT I deleted the .class file thinking that I could change the source file, recompile using javac, and it would create another test.class in the binary folder. It did not. -sigh-
I'm getting an error when trying to compile a GWT application on an AWS EC2 Instance under AMI Linux.
I already installed Java and have it in directory /usr/lib/jvm/java-1.7.0-openjdk.x86_64.
I also set up the enviroment variables:
$JAVA_HOME = /usr/lib/jvm/java-1.7.0-openjdk.x86_64
$PATH = /sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin;/usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin
So, when I try to run the command:
java -cp
"/var/lib/gwt/gwt-2.6.1/gwt-dev.jar;/var/my-project-source-folder"
com.google.gwt.dev.Compiler com.mypackage.MyClass
I'm getting this error:
Error: Could not find or load main class com.google.gwt.dev.Compiler
I downloaded and unziped GWT 2.6.1 again but the files are fine. The same command is working perfectly in my Windows machine. Do you know what's happening?
Ok, this is embarrassing.
Here is the answer:
I was separating the paths with ; (Windows) instead of : (Linux). BTW, who would think in separate things with :, you Linux guys know how to make hard the easy...
I am using MAC OSX
I already follow the instruction on 0mq official site to install
when i compile it , i dont get any error.
But when i run the following command
java -classpath /Users/john/jzmq/ -cp $(lein classpath) storm.starter.WordCountTopology
I got the following error.
java.lang.UnsatisfiedLinkError: no jzmq in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at org.zeromq.ZMQ.<clinit>(ZMQ.java:34)
at storm.starter.spout.RandomSentenceSpout.nextTuple(RandomSentenceSpout.java:39)
at backtype.storm.daemon.executor$fn__3985$fn__3997$fn__4026.invoke(executor.clj:502)
at backtype.storm.util$async_loop$fn__465.invoke(util.clj:377)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:724)
My setting
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
I also have zmq.jar under
/usr/local/lib and
/usr/local/share/java
I read through all the google search I can found. Still no crew why my one is not working
In addition to setting the JAR classpath, you need to specify where the jzmq .so library files reside. Did you build zmq, libzmq, and jzmq exactly as described in the directions? If so, you should see the .so library files in /usr/local/lib and zmq.jar in /usr/local/share/java, confirm that, then logout/login based on this, then try this:
java -Djava.library.path=/usr/local/lib -cp "/usr/local/share/java/zmq.jar:/Users/john/jzmq/<your jar here>" storm.starteer.WordCountTopology
Hope it helps