Can't compile GWT application on AWS instance (Linux) - java

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...

Related

Java code runs through IDE but fails from terminal

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

pyspark not able to start

I am having Windows 8.1 operating system. I installed apache spark and then, installed Java JDK. I am using git bash in windows. I am having below setting in my .bash_profile of git bash.
export SPARK_HOME="/c/tools/spark-2.3.1-bin-hadoop2.7"
export PATH="$SPARK_HOME/bin:$PATH"
export JAVA_HOME="/c/Program Files (x86)/Java/jdk1.8.0_181/"
When I try to call pyspark, I am getting error as given below.
/c/tools/spark-2.3.1-bin-hadoop2.7/bin/pyspark: line 45: python:
command not found Error: Could not find or load main class
org.apache.spark.launcher.Main
I tried running spark-shell in the path "/c/tools/spark-2.3.1-bin-hadoop2.7/bin/". Still getting the same error.
Please help me in making pyspark running in my machine.
I was finally able to make pyspark work in Windows, by following the steps in the blog
http://nishutayaltech.blogspot.com/2015/04/how-to-run-apache-spark-on-windows7-in.html
I had to install few more tools and set environment variables and finally make it working.

Having issues installing Hibernate3 on Debian Server

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.

Deploy Java on Heroku, Cannot find main class in target\dependency

I try to deploy java on Heroku. I follow the steps on Heroku
,But I get error on
java -cp target\classes;"target\dependency\*" HelloWorld
the error is :
Error: Could not find or load main class HelloWorld
How can I solve it? Is it case sensitive?
I found helloworld key word in pom.xml, so I try to change it to HelloWorld. It still does not work. btw, I am running windows 7(64 bit) with jdk1.7.0_05.
Looks like you are using Windows-style path for the -cp flag. Heroku runs on Linux, so you probably need to change that to java -cp target/classes:"target/dependency/*" HelloWorld in the Procfile you are deploying to Heroku.
For any avid readers who are trying to follow Heroku's getting started tutorial and are attempting to deploy locally and are receiving this error...
It is likely that you haven't built the target classes locally (they don't explain it very well in the tutorial).
If you are following the getting started guide with Maven then execute the following maven command in your project root folder to build your target locally:
mvn clean install
After that the local deployment commands like:
heroku local web -f Procfile.windows
should work as expected. (Obviously substitute Procfile.windows with just Procfile if you are not deploying under Windows)
You should then see something like:
Started ServerConnector#4d29c891{HTTP/1.1}{0.0.0.0:5000}
and can access your application locally by navigating to localhost on the port that was displayed:
localhost:5000

Compiled OK but NoClassDefFoundError when running

I'm trying to send an email using JavaMail API.
I have jdk 1.5 installed in my home directory from self-extracting binary. I'm on Ubintu 9.10
I compile the program using the next command:
~/jdk1.5.0_22/bin/javac -classpath ~/jdk1.5.0_22/jre/lib/javamail-1.4.3/mail.jar:~/jdk1.5.0_22/jre/lib/jaf-1.1.1/activation.jar hw.java
It compiles OK. As you can see I have specified the path to mail.jar and activation.jar
Now I try to run the app using the next command:
~/jdk1.5.0_22/bin/java -classpath ~/jdk1.5.0_22/jre/lib/jaf-1.1.1/activation.jar:~/jdk1.5.0_22/jre/lib/javamail-1.4.3/mail.jar:. HelloWorldApp
I get an exception java.lang.NoClassDefFoundError: javax/mail/Address
Why can it find classes when compiling and cannot do it when running?
How to correctly run my app?
Thanks in advance
That class should come from your mail.jar. I'm not sure your classpath is being parsed properly. The tilde (~) is a shell function and needs expanding before being sent to the Java process. Have you tried removing the ~ and replacing with /home/{whatever} ? I suspect that's the issue.

Categories

Resources