java error in org.apache(netbeans) - apache

I have a code written in java. when i load it in NetBeans it shows an error in the java code import line: " The import org.apache.hadoop.conf.Configuration dosent exist"
How can i fix this error..??
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

You have to add proper library in project properties.
Or maven dependency if you are using maven.

Related

Running evosuite generated tests in Eclipse

I have generated the test cases using evosuite from the command line in Linux.
I try to execute the tests in Eclipse. I have imported in my project the evosuite-standalone-runtime-0.2.0.jar.
All the imported classes regarding evosuite are marked with the error sign.
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.evosuite.runtime.testdata.EvoSuiteFile;
import org.evosuite.runtime.testdata.EvoSuiteLocalAddress;
import org.evosuite.runtime.testdata.EvoSuiteRemoteAddress;
import org.evosuite.runtime.testdata.EvoSuiteURL;
I don't understand this. It looks like these classes are unknown even though are in the imported jar file.
Try:
Right button in your project-->build path--> Add External Archives
(select evosuite-0.2.0.jar)
Do not forget to put the two classes in the project. (ESTest.java and ESTest_scaffolding)
I hope this helps.

pyttsx: No module named 'engine'

I'm trying to install TTS package by using this. Everything was okay until I tried to execute the following command:
import pyttsx
I got back this error:
File "/usr/local/lib/python3.4/dist-packages/pyttsx/__init__.py", line 18, in module <br>
from engine import Engine<br>
ImportError: No module named 'engine'
Any help would be appreciated. Thank you!
Guys there is an updated package compatible with Python3 :
pyttsx3
Works offline with no delay in the sound produced.
Installation:
pip install pyttsx3
Visit https://pyttsx3.readthedocs.io for the full usage docs.
Thanks!
Combining the advice from Jacob Tsui and Jokhongir Mamarasulov worked for me. To summarize:
In site_packages/pyttsx/init.py, modify "from engine import Engine" to
from .engine import Engine
Then, in site_packages/pyttsx/engine.py,
Modify import driver to
from . import driver
Modify except Exception, e to
except Exception as e
And finally, in site_packages/pyttsx/driver.py modify except Exception, e to
except Exception as e
See the responses from the aforementioned authors for the rationale behind these changes.
I just had the same problem, try using pyttsx3 instead of pyttsx
First install pyttsx3
pip install pyttsx3
and change the
import pyttsx
for
import pyttsx3
After that you have to change engine import (if you're using it in your main .py file). Use engineio instead. Install it
pip install python-engineio
then change import engine for import engineio and change your variables.
Here's an example
import pyttsx3
# import engineio #engineio module is not needed.
engineio = pyttsx3.init()
voices = engineio.getProperty('voices')
engineio.setProperty('rate', 130) # AquĆ­ puedes seleccionar la velocidad de la voz
engineio.setProperty('voice',voices[0].id)
def speak(text):
engineio.say(text)
engineio.runAndWait()
speak("What do you want me to say?")
while(1):
phrase = input("--> ")
if (phrase == "exit"):
exit(0)
speak(phrase)
print(voices)
Hope this helps someone
For Python3, please install the latest version via pip3 install pyttsx3 and call import pyttsx3.
I found out the solution. Library was created in python2 language and there are not a lot of differences between those 2 versions, but exclusively in this case that occurs.
Move to your DP folder and change in engine.py "except Exception as e" instead of "except Exception, e", line 67. Do the same in drive.py, line 105.
Because of files are secured try to execute, e. g.
sudo nano engine.py (or drive.py)
I guess I helped everyone with that kind of problem. :)
Modify site_packages/pyttsx/init.py "from engine import Engine" to
from .engine import Engine
Modify site_packages/pyttsx/engine.py "import driver" to
from . import driver
Reason: The import statement "from engine import Engine" tells python to import Engine module from directory engine. In our case engine is not a directory, it's a python file, engine.py. So we need to tell python to import this engine module from current directory (".").
I used this code after
pip install pywin32 pypiwin32 pyttsx3
and it worked perfectly for me
import os
import sys
import pyttsx3
engine = pyttsx3.init()
engine.say('hello world ')
engine.runAndWait()
I had the same issue.
First Try this command:
pip install pyttsx3
and then don't use
import pyttsx
use this
import pyttsx3
It will work.
pyttsx: No module named 'engine'
File "/usr/local/lib/python3.4/dist-packages/pyttsx/__init__.py", line 18, in module <br>
from engine import Engine<br>
ImportError: No module named 'engine'
If the above one is your error then try install pyttsx3 instead of
pyttsx.
Before installing check your python version, then download the version which is compatible to your python version.
Refer this link to get the previous versions of pyttsx3
REASON:
The reason we get the above error is because of the pyttsx3 version
which is not supported by your python version. Even if you get the error then
FOR pyttsx
Modify the init.py file located in
C:\Users\YOUR USER\AppData\Local\Programs\Python\Python38-32\Lib\site_packages\pyttsx\init.py
Change
from engine import Engine
to
from .engine import Engine
pyttsx
Modify the engine.py file located at C:\Users\YOUR USER\AppData\Local\Programs\Python\Python38-32\Lib\site_packages\pyttsx\engine.py
Change
import driver
to
from . import driver
These are the two main solutions for the above error

org.apache.http, org.apache.xerces

So im trying to import
import org.apache.http.HttpEntity
import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.DefaultHttpClient
import org.apache.http.message.BasicHttpResponse
import org.apache.http.params.HttpParams
import org.apache.http.params.HttpConnectionParams
import org.apache.http.util.EntityUtils
import org.apache.xerces.impl.XMLEntityManager.Entity
Non of these are found. I have a different project that is importing the exact same things and it works. But not on this project. Any ideas on why this could be happening?
---------------------------------------------------
tomcat 2.1.0 -- Apache Tomcat plugin for Grails
webxml 1.4.1 -- WebXmlConfig
Any help would be greatly appreciated. Thanks!
A common problem is usually that the libraries (xerces) are not imported, you can download it from here.
Oficial web
Cheers.

Use glade with pygobject Gtk3

I am converting a script to use Gtk3 using the migration guide (Porting GTK2 to GTK3). I converted my import pygtk to a from gi.repository import Gtk and so on...
I'm stuck because the glade module was loaded from module gtk:
import gtk
import gtk.glade
but there's no way now to do that anymore.
Note that I would only need a replacement for gtk.glade.XML()...
Well, the solution is pretty obvious, after calling to Gtk.Builder() one needs to convert the old glade interface with the gtk-builder-convert command to get the interface file in the right version.
$ gtk-builder-convert myui.glade myui.ui
And then, in the python script:
from gi.repository import Gtk
builder = Gtk.Builder()
builder.add_from_file("myui.ui")
Thanks to Riccardo.
This should work
from gi.repository import Gtk
builder = Gtk.Builder()
builder.add_from_file("project.xml")

UPS developer API missing ja

I am looking for what jar library to import into my software. I am using ups's Shipping_Pkg_Gnd.zip for a spring board to provide shipping label generation. However they did not provide a .jar library in any of sample code that they provide. Does anyone know where to get this library.
Here are the imports that will not work because I do not have the required developer API
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipmentErrorMessage;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.BillShipperType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.InternationalFormType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.LabelImageFormatType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.LabelSpecificationType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PackageType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PackageWeightType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PackagingType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PaymentInfoType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ProductType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ProductWeightType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.RequestType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ServiceAccessToken_type0;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ServiceType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipAddressType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipFromType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipPhoneType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipToAddressType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipToType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipUnitOfMeasurementType;
I had the similar issue, and the solution is to use wsimport.sh to generate the jar/class files from the wsdl.
So you have to copy the following six files to the same folder
$ mkdir ups_ship && cd ups_ship
$ ls -1
common.xsd
Error1.1.xsd
IFWS.xsd
ShipWebServiceSchema.xsd
Ship.wsdl
UPSSecurity.xsd
$ wsimport.sh -verbose -keep -extension -target 2.0 Ship.wsdl
Generated code:
$ ls -1 com/ups/wsdl/xoltws/ship/v1/
ShipAcceptErrorMessage.class
ShipAcceptErrorMessage.java
ShipConfirmErrorMessage.class
ShipConfirmErrorMessage.java
ShipmentErrorMessage.class
ShipmentErrorMessage.java
ShipPortType.class
ShipPortType.java
ShipService.class
ShipService.java
Now you can put all your *.class files in a package and use it in your project:
$jar cvf com_ups_wsdl_xoltws_ship_v1.jar ./com/ups/wsdl/xoltws/ship/v1/*.class
Your new jar:
$jar tf com_ups_wsdl_xoltws_ship_v1.jar
META-INF/
META-INF/MANIFEST.MF
com/ups/wsdl/xoltws/ship/v1/ShipAcceptErrorMessage.class
com/ups/wsdl/xoltws/ship/v1/ShipConfirmErrorMessage.class
com/ups/wsdl/xoltws/ship/v1/ShipmentErrorMessage.class
com/ups/wsdl/xoltws/ship/v1/ShipPortType.class
com/ups/wsdl/xoltws/ship/v1/ShipService.class