Setting environment variables Linux - java

I am configuring my study environment :) on Linux server: I have installed java, oracle database, tomcat, and I have set JAVA_HOME, ORACLE_HOME variables for all users and modified the .bash_profile files as I read it is the only way to make things permanently set. However I am not sure what variables do I need to set for TOMCAT, when I try to start tomcat from another user different from root[even here I have to go inside tomcat's bin folder], I see that the process is trying to use CATALINA_HOME, CATALINA_BASE,CATALINA_TMPDIR and CLASSPATH [for bootstrap.sh (I am not sure why it needs bootstrap.sh)], anyway my question is which variables do I need to set for tomcat? Do I need to set all of them in root and all other users .bash_profile files? I need some clearification because I am really fed up with configuration having a lot to know beyond that, just need help.
More to that I think I have installed MAVEN [MAVEN_HOME not set either], I say I think because when I try
locate maven
I have the following result:
/etc/maven
/etc/maven/maven2-depmap.xml
/usr/local/apache/tomcat/apache-tomcat-6.0.37/webapps/docs/maven-jars.html
/usr/share/java-utils/xml/maven2jpp-mapdeps.xsl
If I try the following I have not output
locate maven | grep bin
[Not sure if this is a good question to ask the server, since deep in /etc/maven ls -la show me there is total 32 but I can only see maven2-depmap.xml]
The question is, looking at the files found when I tried locate maven, can anyone tell if I have installed it or not? :):)
Further I need To install GIT following some installation guide I had found it is been a week I don't really remember which one was that, I started by downloading curl_devel, gettext_devel some other *_devel stuff [I don't know what they are and not sure if I should know about them] and when I tried to install them, they required git to be installed I looked around for git packages to download but after 7 to 10 minutes I didn't find where I can really get git packages, but since I didn't give it much attention this question is not as important as others. what I want to know is, once I get git installed which environment variables will I have to set?
Thank you very much for taking time to read and help. I appreciate.

I think the other simple round about can the changing the user of the TOMCAT. Set it to the root user.
This will be useful only if you have set correct path and tomcat is working properly with root user.
I also dont know if this is recommended or not.

Related

Multiple persistent errors IntelliJ

I run IntelliJ IDEA version 2019.2.3 on a Windows 10. We use the same version at school. It works there, but not on my home laptop. I've set the environment and CMD shows the correct path of Java. The JDK 1.8 is also properly installed. Please , what could the problem be ?
I want to thank everyone for taking the time to give a helping hand !
The answers I received via Support at Jet Brains crashed the app or made it unusable. The FAQ links they provide is a collection of vague workarounds. And, especially for someone that is a total beginner and has no guidance in editing non-destructively, it won't work.
I would also like to post the only solution that worked on the Cyrillic issue with IntelliJ Idea, since I know other people have had it as well and I hope it will be useful for others in the future. This came from my teacher at Link Academy Bucharest, Mr. Bogdan Posa.
The actual thing that needs to be modified is the existent file called idea.properties, found in the BIN folder within the Idea installation folder. This only worked after I had re-installed Idea in a different place than "C:/Users/Cyrillic username/" which Idea was picking by default to install itself. So it will be something like C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2019.2.3/bin. The idea.properties file can also be opened with Notepad to avoid crashing Idea (happened many times). Within the text editor, find and edit the value of idea.config.path, removing the comment and writing the new location/path of the Idea installation folder. Windows might not allow you to save the edited idea.properties file in that original location and it might ask if you want to save it in the Documents folder instead. Just say yes, save it there and then copy/paste it back to the Bin folder, it will accept it. After this, you will have to open Idea with "right-click open as Administrator". Apparently, as long as there still is a path containing Cyrillics in a username, Idea will not run your project so if you can't avoid it, just play along and Run as Admin when opening Idea. That's how it NOW WORKS for me, after several re-installing and changing properties, environments and every damn thing. I was close to hugging ECLIPSE.... :) Hope this helps, Cyrillic users !
No, not at all. This is a kind of wird exception.
You can change the config location of intelliJ.,
This can be done in:
IntelliJ Menu: Help | Edit Custom Properties…
Then it will create a file under: IDE_HOME\bin\idea.properties
Example of the configs:
idea.config.path=c:/work/idea/config
idea.system.path=c:/work/idea/system
idea.plugins.path=c:/work/idea/plugins
More info:
https://intellij-support.jetbrains.com/hc/en-us/articles/207240985-Changing-IDE-default-directories-used-for-config-plugins-and-caches-storage

Java JDK installer won't run

I tried the other solutions but they didn't worked, so please don't just say "It's a duplicated so now you have to open this link." Because I tried them.
I have Windows 8.1 and I installed Java 8 JDK some days ago, now I unistalled it because I've had some problems with it (like the PATH for cmd was not set), and after unistalling it I tried to open the Java installer, after the UAC popup nothing happen. I tried opening the installer "sandboxed" with the program "Sandboxie", the Installer opened 2 services, after a few seconds another service opened and then every service closed.
I have no error, no logs, nothing.
P.S.
I tried downloading again the installer 3 times, nothing changed.
Edit:
JRE Installer doesn't start either.
Edit:
I'm actually in safe mode with internet connection and the installer still don't want to run... I don't know what to do now...
I tried with "sfc /scannow" and it said there was no problem, I tried "DISM.exe /Online /Cleanup-image /Restorehealth" too, no problem got reported.
Edit:
I tried running the installer with a Guest account, nothing changed. Anyway I found a solution.
I searched for everything that contains "Java" in C:\ and I found some value (that could have prevented Java Installer from running because it thought Java was already installed), I deleted them (carefully, don't just delete everything on your computer, that's not the way.)
Now I tried launching the installer and.. Here we go! Finally I can install it.
Thanks to anyone who tried to help me, I appreciate it.
In my case problem was in C:/Users folder. Initially my OS language was not English, after changing, it causes some errors. I couldn't install jdk, couldn't run some desktop tools. After looking for the solution, I could found it. My user name in Users folder had non English letters. So, I changed name of user and it solved my problem:
https://superuser.com/questions/890812/how-to-rename-the-user-folder-in-windows-10
You should add java in Path:
Open the System Properties.
Find the Advanced Tab in the Properties Window. Click Environmental Variables.
Scroll down in the System variables and find the PATH variable.
Select the PATH variable and click the Edit button.
Add the Java installation path to the PATH variable (dir_java/bin)
And also create system variable JAVA_HOME
What antivirus are you using?
If your av has some kind of process viewer that you can use to see when it starts and when it terminates and if it is marked a suspicious. Here is a screenshot from my av. I use comodo image here
If your av doesn't have this feature, try turning it off during the installation. Remember to turn it back on after you're done

installing java on a linux server

completely new to this so apologise for the question.
I have current been asked to deploy a jar on a linux server at work. I have sucessfully logged into ther server using ssh and transferred my jar on to it. However when I run any java command it says command not found.
I ran
locate java
and
locate jar
which both return, so im guessing java is installed? What do i need to do?
Thanks in advance
It sounds like your path has not been set up to fit your Java needs. You can do either of two things:
Type out the full path of where java is located, and use this full path instead of "java".
Edit your PATH to include java. Here's some information on how this is done: http://www.java.com/en/download/help/path.xml
I think you have to check to make sure that java is installed and the path for it is set too.
Whe you type locate jar it's most likely going to return any other jar including the one you have just added. To know if java is installed, you should instead use the following command java, if the result is something like the program cannot be found... then it means there is not java. You could also use java -version which will also tell you which version is installed. If it's for running purposes then you will be good with that.
First try the command which java, it would show you if you have java installed if not download it and install,run it. Then you can run the jar file as per you requirement. This link shows you how to install and configure java.
http://www.java.com/en/download/help/linux_install.xml
Thanks & Regards,
Alok Thaker

Can't figure out cause for NoClassDefFoundError: aspose/pdf/Paragraph

I can't get any pages of my webapp to load (locally on Tomcat 7.0.2.6), due to this NoClassDefFound error. I'm at my wits end trying to figure out what the cause is, here is what I know:
My coworker has this project successfully running locally (on Tomcat) and on our development server (WebLogic).
I have done a fresh pulldown from svn so my code is exactly the same as his. I've verified that I have a shared library reference to Aspose (and that the required .jars are in there), and that weblogic.xml has an entry for it.
We saw this same error when initially deploying on WebLogic because the Aspose library was named incorrectly, but it ran fine locally on his Tomcat server.
I've tried cleaning and rebuilding the project to no effect.
As best as I can figure, it has to be either a Tomcat issue, or maybe an Eclipse setting.
Has anyone encountered a similar situation? Any ideas on what to try to resolve this?
First thing you need to do is determine if you are colliding with another class with the same name and package. The easiest way to do this is with the cygwin/linux console, save this shell script to a file say, findjar
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
put it in your path and navigate to the root of the server instance and run the script like this
findjar . yourclass
Note the period, dont forget it. this will return if you have multiple classes with the same name in your project.
once your sure the project is clean and there is only one copy of the class, i would try actually adding your shared libraries folder to the websphere server instances JVM arguments. to do that:
Go into the admin, click on servers
Open server types, click on websphere application servers
You should see your server listed there, click on it
On the right hand side, you will see a section “server infrastructure” and below that is a subsection “Java and process Management”
Open that section and click on “Process Definition”
On the process definition screen is another right hand column. Click on “Java Virtual Machine”
Yes, finally we are on the correct screen, there is an end in sight here, I promise
On the virtual machine page, there is a large text field labeled “Classpath” What you need to do is enter the full path to the shared libraries folder
its odd and makes no sense to have to do it, but i have had to do that in the past to allow my code to see the properties files in a shared resource.
It is possible that your colleague has java librarys installed within his Tomcat instance itself.
Take a look in the Tomcat directory for some lib folders (I cant remember the exact location and I think it changes based on the version) but something like ${CATALINE_HOME}/common/lib
Verify that he doesnt have differen JAR files in his tomcat installation as yours.
From this question: Does Tomcat load the same library file into memory twice if they are in two web apps?
They are apparently stored here:
Tomcat 6 $CATALINA_HOME/lib
Tomcat 5 $CATALINA_HOME/common/lib

ClassNotFoundException: BasicDataSourceFactory

I have a JAVA application that runs fine in my local Windows7 environment on Tomcat7. I am trying to put this into production in a Linux environment.
Everything is done and is working fine except when my application tries to access the DB. Operations where DB is not involved, it works fine.
The error I get is
java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
This class is part of tomcat-dbcp.jar. This is placed in my $CATALINA_HOME/lib folder. Why is this still not getting picked up? Please help!
UPDATE: I also opened up the .jar file and checked. The org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.class file is present.
Was finally able to crack it. My mistake - I was relying only on echo $CATALINA_HOME to check its location. Turns out that this can be misleading.
It is better to use
ps aux | grep catalina
In the output that comes look for catalina.base and catalina.home. The path given in front of these variables is the path from where Tomcat libs are being fetched. I had done a default installation and found the libs under /usr/share/tomcat7. As it turns out, the default installation done using yum did not provide the tomcat-dbcp.jar file. Instead it provided the commons-dbcp.jar. Read about tomcat-dbcp vs commons-dbcp
Changing the lib files under the usr/share/tomcat7 folder required me to use sudo bash. Also you may notice that the lib folder under /usr/share/tomcat7 is a simlink. Just do ls /usr/share/tomcat7 -l to get the parent location. You will be able to make changes only in the parent location.
Similar things can be checked for server.xml which is also finally being picked from /usr/share/tomcat7 itself.
The best way to manage all these is to create your own simlinks so that you don't need to bother about going to various locations after the first time.
Thanks to everyone who tried to help.

Categories