w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Can eclipse automically reduce all package calls to full imports?
Select the fully qualified classname java.util.logging.Logger then click Source > Add Import (Shortcut: Control + Shift + M)

Categories : Java

Eclipse java project where directory structrure != package structure
This is not possible in Java, the runtime system always looks for a/b/c as directory structure for a specific class in package a.b.c. See http://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.4

Categories : Java

Relative imports in Python 3
unfortunately, this module needs to be inside the package, and it also needs to be runnable as a script, sometimes. Any idea how I could achieve that? It's quite common to have a layout like this... main.py mypackage/ __init__.py mymodule.py myothermodule.py ...with a mymodule.py like this... #!/usr/bin/env python3 # Exported function def as_int(a): return int(a) # Test function for module def _test(): assert as_int('1') == 1 if __name__ == '__main__': _test() ...a myothermodule.py like this... #!/usr/bin/env python3 from .mymodule import as_int # Exported function def add(a, b): return as_int(a) + as_int(b) # Test function for module def _test(): assert add('1', '1') == 2 if __name__ == '__main__': _test() ...and a main.py l

Categories : Python

What are the rules for __all__ and relative imports?
__all__ has no effect in the case you're describing. It only affects what happens when you do from package import *. See the documentation as well as previous questions (which I found by googling python __all__).

Categories : Python

Why sub-package imports from parent package?
I have two subpackages of MyPackage as MyPackage.P and MyPackage.Q Now those are not subpackages of MyPackage. They are just different package, creating a completely different namespace. There is no such thing as parent-child relationship between packages. You can say that, they are just creating a logical grouping and nothing more. They will result in different directories created.

Categories : Java

Tried to use relative imports, and broke my import paths?
You probably have your own urllib2 python file in your system path, perhaps in the local directory. Don't do that, as it breaks werkzeug (and other python code). To be compatible with both python 2 and 3, werkzeug uses constructs like: try: from urllib2 import parse_http_list as _parse_list_header except ImportError: # pragma: no cover from urllib.request import parse_http_list as _parse_list_header The from urllib2 import parse_http_list as _parse_list_header line could throw a ImportError exception if you have a local urllib2.py module or urllib2/__init__.py package that masks the standard library file. Because the first import throws an ImportError, the second line is executed, which also fails because the urllib.request package is only available on Python 3. From your pro

Categories : Python

Module imports from relative folders with regular execution
The package isn't pkg2; it's app.pkg2. Set __package__ accordingly: if __name__ = '__main__' and __package__ is None: __package__ = 'app.pkg2' If that's not the problem, then app probably isn't on the path. The best solution I know of is to put it on the path (by moving app or putting its current directory in PYTHONPATH), but if you're looking for a way to let modules in app see each other without being visible to external modules, I don't know of anything. It seems like it could be useful.

Categories : Python

Running Python on a module with relative imports from another directory
Get the relative path: base_path = os.path.abspath('../my_other_package/') #or any relative directory append this to the system path (only temporary, will be deleted after execution): sys.path.append(base_path) import the file you need in that path: import my_other_module.py I believe it you may need a file named __init__.py (with nothing in it) if you wanted to import the file as import directory.file (correct me if I'm wrong). This thread shows alternate approaches.

Categories : Python

Organising python packages avoiding relative imports
lets say that i have this folder structure.. package1 |_ init.py |_ constants.py |_ package2 |_ init.py |_ constants.py then you can add import os import sys sys.path.append(os.path.dirname(__file__)) inside the package1/init.py then you can do from package1 import constansts as con1 from package1.package2 import constansts as con2

Categories : Python

I'd like Python to look into a package first for imports
PEP 238 is about absolute and relatve imports. As I understood, from . import bar would import the right thing. Reading that PEP could help you understanding the different ways of importing modules. They point out, that absolut imports are the default, because it can be used for everything: import foo import bar.foo import sys In contrast to: import ..foo import .foo import sys #absolute

Categories : Python

Python Package Design And Circular Imports
Using a fully-qualified path isn't really a hack; it's probably the proper solution to this particular issue. If you want a shorter name to type out, you could do something like this: import filesystem.directory class File(object): def __init__(self): self._Directory = filesystem.directory.Directory def foo(self): some_dir = self._Directory(...) This also makes it trivial to swap in a mock if you're testing, et cetera.

Categories : Python

What function in R package httr performs request and imports activities from Fitbit API?
Try this: activities <- GET(url = "http://api.fitbit.com/1/user/-/activities/date/2013-06-07.json", config=sig) content(activities) That will give you the results in a list from which you can more easily extract what you are after.

Categories : R

jar file not working for imports in Eclipse
The tutorial clearly says "Download and Extract" That does not mean "Download and Rename". It means download the file and then Use a file compress/uncompress utility to extract the zipped files format. Search in the extracted files to find the relevant jar file and import that file. 1. Download & extract twitter4j library from twitter4j-android-2.2.6.zip (slimmed version for Android platform). Here is the direct link If you uncompressed correctly then do the following Right sure that the folder where you copied the twitter library shows up in the Lib path for the project. Right click on the project --> Select 'Properties' ---> Select 'Java Build Path' From the Left hand Menu ---> Select Libraries Tab. Review List of Libraries(expand if needed ) to see if the twitter jar files show

Categories : Eclipse

Eclipse with Jython doesn't understand Java Imports
Have you created a new PyDev project for this? Without that, Eclipse won't be able to find your full Jython installation, which could explain the underlinings. In my environment (Eclipse Kepler, PyDev, and Jython 2.5.2) it works correctly.

Categories : Java

Change project file structure after migrating from Eclipse to Android Studio gradle structure
While migrating your project from Eclipse to Android Studio, no change have been done on project structure. The only that have changed are new .iml and .gradle files. Your java code stays in project/src/ folder, and has not been moved in project/src/main/java folder (like in a new created project from AndroidStudio). Your AndroidManifest file also stays in the project/ folder and has not been moved in project/src/main/ folder (like in a new created project from AndroidStudio). At migration, the build.gradle file is customized in order to be able to compile with the old structure is described in the gradle documentation : Configuring the Structure For a new created project in AndroidStudio, the sourceSets part of the build.gradle file : sourceSets { main.java.srcDirs = ['src/java']

Categories : Android

I used m2eclipse plugins in eclipse.why the imported package still cannot be resolved by eclipse?
First of all, you're not using the m2e plugin; while it may be installed, it's not activated for this project: There is no little "M" on the project's icon The classpath doesn't include an entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER From what I can see, Eclipse can't resolve the dependencies since the variable M2_REPO isn't defined (if it could, you would see the absolute path to the JARs in the upper image after the symbolic path). To fix this, go to Preferences and search for "Classpath Variables". Add M2_REPO there with the correct path (default is $HOME/.m2/repository). If it already exists, make sure the path is correct. Alternatively, right click on project and select "Convert to Maven Project" under "Configuration".

Categories : Java

Meteor package css relative resource path
Reference your image using package relative path, ie : /packages/my-package/css/my_css.css : .my-class{ background-image:url('/packages/my-package/img/my_image.png'); } Explicitly ask Meteor to bundle it on the client via the package system API : /packages/my-package/package.js : Package.on_use(function(api){ var clientFiles=[ // css "css/my_css.css", // img "img/my_image.png" ]; api.add_files(clientFiles,"client"); }); This way your package will be truly generic : users will just have to "mrt add" it to automatically serve your image to the client without messing with /public which is reserved for application-specific static files. As an example, consider a bootstrap3-glyphicons package : packages/ -> bootstrap3-glyphicons/ ----> b

Categories : Meteor

How do I structure my Python package?
You could use the second structure, but in your __init__.py, simply have... from .project import PublicClass1 from .project import PublicClass2 from .project import PUBLIC_CONSTANT_A ... Basically, only importing in __init__.py what you actually want to be public, while keeping __init__.py mostly free of code logic.

Categories : Python

Android Studio Project Structure (v.s. Eclipse Project Structure)
The mystery: Android Studio's Project Structure and Build System I don't know if this is because of the Gradle Build System (I'd wager it is), but I'll tell you what I've understood so far. Update 4: 2014/09/11 Added Cheat Sheet for BuildTypes, Flavors and Variants(I finally feel confident to write this :D) Update 3: 2014/09/11 Updated the comparison workspaces and projects to be precise Update 2: 2014/04/17 Added more detail to AS project structure Update 1: 2013/07/29 Added IntelliJ Project Structure The IntelliJ's Project structure (shown at the end) is for IntelliJ with the android plugin. The Android Studio, however, has a project structure divided like so: Structure: Projects and Modules module in Android Studio is like a project in Eclipse project in Android Studio is like a

Categories : Android

Can't get EAR package structure correctly with Maven
Ok, after I checked out a project from various maven archetypes I found the error... the minimal error... it's always a minimal error costing huge amounts of time... In the dependencies section of the ear file, where I define my ejb as dependency, just add this: <type>ejb</type> so it's: <dependency> <groupId>at.betrieb.projekt</groupId> <artifactId>extended-ejb</artifactId> <version>1.0</version> <type>ejb</type> </dependency> Afterwards it works correctly. Obviously it is wrong on the IBM page and on many other pages. Besides I found out the following section is also outdated, and can be completely removed from the ear-plugin section: <jarModule> <groupId>at.betrieb.projekt<

Categories : Maven

How to create jar file with package structure?
You want $ jar cvf asd.jar . to specify the directory (e.g. .) to jar from. That will maintain your folder structure within the jar file.

Categories : Java

Clarification in Java Package structure
No, they won't clash. If that was a problem, you couldn't use several libraries from, fo example, Apache at the same time, because they all put their classes under some sub-package of org.apache. You can see the package tree of all the classes in the classpath as a giant tree containing a merge of all the package trees of all the jars and directories listed in the classpath. If you had two classes with the exact same package and name in two different jars/directories in the classpath, then that would be a problem, because only the first one would be available, and you can't (AFAIK) have any guarantee about the order of the WEB-INF/classes and jars under WEB-INF/lib in the classpath.

Categories : Java

EclipseLink MOXy exception due to package structure
You need to have one binding file per package. BTW when you specify the package name in the xml-bindings element you don't need to fully qualify the name on the java-type element.

Categories : Java

A tool to validate the structure of a Python Package?
If you call a module using: python -m module Python will load/execute the module, so you should catch crude syntax errors. Also, if module has a block like: if __name__ = "__main__": do_something() It will be called. For some small self-contained modules I often use this this block to run tests. Given the very dynamic nature of Python, it is very hard to check for correctness if the module author is not using TTD. There is no silver bullet here. There are tools that will check for "code smells" and compliance with standards (dynamic languages tend to generate a profusion of linters). pylint PyChecker PyFlakes PEP8 A good IDE like PyCharm can help, if you like IDEs. These tools can help, but are still far from the assurance of static languages where the compiler can catch ma

Categories : Python

How do I create a class with constant properties accessible to other classes within a package folder structure?
Are you sure you have "RootFolder" added on the path? Here is a quick test I did, which works just fine (I'm running R2013a): root/+pkg/MyClass.m classdef MyClass properties (Constant) Version = '1.0'; Info = struct('Name','MyClass', 'Version',pkg.MyClass.Version); end end Now >> addpath('/path/to/root') >> pkg.MyClass.Version ans = 1.0 >> pkg.MyClass.Info.Version ans = 1.0 So I was able to even directly index into the returned structure. Note that if you want to reference any of the constant properties inside other properties, you have to use the fully qualified name including the package name (just like we did for the "Version" property inside the structure)

Categories : Matlab

Something wrong with package explorer in eclipse?
It is likely that some plugin has caused such behavior. Install new clean Eclipse (no new to uninstall your current). Then try to open your project in that Eclipse, it should work OK. Then make notice what plugins are installed, and if they change the behavior.

Categories : Eclipse

In Eclipse, how can I export a package and all sub-packages as a jar?
Go to file->export->JAR file, there you may select "Export generated class files and sources" and make sure that your project is selected, and all folder under there are also! Also, make sure they are in the Build Configuration -> Order and Export area, and they are checked for export. If all else fails, try FatJar. It detects all dependencies and automatically bundles them into the JAR. In Eclipse you can use FatJar by using the Build Fat Jar option for Java projects.

Categories : Java

How do I use PDFBox with Eclipse? Does it package in jar files?
You will need to send both the jar you produce (from building your project) and the PDFbox jar. The PDFbox far file must be in the CLASSPATH when you run your application. Add a jar (for the purpose of building only) as follows: select the project, type ALT-Enter (or right-mouse on the project and select properties), click on "Java Build Path", click the "Add External Jars..." button, browse to the PDFbox jar file, click the "open" button, then click the "OK" button (on the properties window). The PDFBox jar file is now in the build CLASSPATH of your project. See step run concerning the runtime CLASSPATH.

Categories : Java

what the meaning for the image about the package in java eclipse?
This means your folder is scheduled to be deleted on the next commit. It is used when your project is under SCM using Subversion. Go to Window -> Preferences -> Team -> SVN -> Label Decorations to see the meaning of all used SVN icons, as shown below:

Categories : Java

Eclipse does't shows errors in Package Explorer
Open the Problems view. It will display all the compile time errors & warning in your open Applications. To open that view follow the steps: Go to Window: Show View: Other: General: Problems. Also to view the errors in Project Explorer, try cleaning the project, as suggested by Vimal Bera.

Categories : Java

How to get the active package path in eclipse workspace
Try to make your path to an absolute path using IPath#makeAbsolute(). You can also transform it to an File using IPath#toFile() and then make it absolute (File#getAbsolutePath()). So in your sample you could write: IPath path = folder.getLocation(); System.out.println("Absolute Path: "+path.makeAbsolute()); System.out.println("Absolute FilePath: "+path.toFile().getAbsolutePath());

Categories : Eclipse

Tolven source to Eclipse project structure
Note sure of your Eclipse version. In 4.2, Select Window>Open Perspective>Other... and then CVS Repository Exploring. In the "CVS Repositories View", right click and select New>Repository Location.... Connection Type: pserver User: anonymous Host: tolven.cvs.sourceforge.net Repository Path: /cvsroot/tolven Use default port Click on OK. You should see something like this: You're going to want this to be an Eclipse Java Project. So create a Java project with separate source and binary folders. In the "CVS Repositories View", right click on the stuff you want to edit in Eclipse and select Check Out As.... Select ...into an existing project, then Next>. Now select the source folder of the Java project you just created. and Finish. You're probably going to want to move the non-Java files

Categories : Java

Eclipse Grails - Does not recognize structure from SVN import
The problem was that the commit had additional information which broke eclipse. I created a new project from the sources, cleared the repo and made the commit based on this tutorial on the main list.

Categories : Eclipse

File and folder structure is changed in eclipse
Are you in the appropriate perspective ? It's been 3 or 4 years I haven't done JavaEE, but I think there is also a JavaEE perspective. Menu > Window > Open Perspective Finally, your problem seems to come from the view you have selected : Menu > Show View > Other > (General > Navigator) In the last picture, you are in the "Project Explorer" view and in the other one in the "Navigator" view.

Categories : Eclipse

How do I put a folder with java files into eclipse's package explorer
Create a new project in Eclipse: File > New > Java Project This will create a project with a src folder. Then copy and paste the Java files into this directory via the file system. If the .java files are packaged you may need to create packages within the src folder. Click the src Folder > File > New > Package

Categories : Java

Eclipse - Search for a word or Phrase inside the package
Search -> Search... or ctrl+H. There is File Search where you can search by text or regular expression and restrict search by scope and/or file name patterns. And there is Java Search which allows you to find declarations, references and occurrences of Java elements.

Categories : Eclipse

Not able to find classes in org.eclipse.jetty.websocket package
You are using the wrong apidocs. You said you are using Jetty 9.0.3, and then linked to the Jetty 7 javadoc. Use the Jetty 9 javadoc. http://download.eclipse.org/jetty/stable-9/apidocs/index.html There's some information in the jetty 9 documentation about the API as well. http://www.eclipse.org/jetty/documentation/current/websockets.html

Categories : Java

After changing package name I get java.lang.ClassNotFoundException on Eclipse
You probably didn't update your imports in your main file (the one who runs the main method). ClassNotFoundException implies that the classloader couldn't find a certain class given the current directives. Eclipse should be sending you a warning about this (underlining the offending imports in red). To organize the imports for a given file directly, use the Ctrl + Shift + O shortcut while editing it.

Categories : Java

How to export an Eclipse builder (or package it) for Importing to other projects?
If you've implemented the builder using the New>Program sequence adding the program you're calling in that manner, then the simplest solution is use the same specifications and add an external tool configuration with the same definition (you may need to delete the definition from the original project builder tab). Once defined as an external tool, the tool can be imported using the import menu on the project builder tab.

Categories : Eclipse

Eclipse type declaration points to wrong package
Assuming that the import from your project corresponding to this class is the right one, and that you chose a package name different from the one used in the jar file : Rename your class, or suppress the ambiguity by prefixing your class name by the package name in your code. Right now, I don't see any other option. org.test.MyClass c = new org.test.MyClass();

Categories : Eclipse



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.