Skip to main content

Questions tagged [java-package]

Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier etc. A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and name space management

java-package
Filter by
Sorted by
Tagged with
477 votes
8 answers
299k views

javax vs java package

What's the rationale behind the javax package? What goes into java and what into javax? I know a lot of enterprise-y packages are in javax, but so is Swing, the new date and time api (JSR-310) and ...
Jaka Jančar's user avatar
  • 11.5k
14 votes
2 answers
41k views

TypeError: 'JavaPackage' object is not callable (spark._jvm)

I'm setting up GeoSpark Python and after installing all the pre-requisites, I'm running the very basic code examples to test it. from pyspark.sql import SparkSession from geo_pyspark.register import ...
Jessica Chambers's user avatar
12 votes
1 answer
14k views

Underscore in package name in Java - is it bad? [duplicate]

Sorry for my English I think that sometimes it is necessary. In my opinion search_result_list, location_provider are easier to read than searchresultlist, locationprovider. What does the ...
Leonid Semyonov's user avatar
9 votes
1 answer
8k views

Exclude packages from TestNG

Consider the following TestNG configuration which runs all tests in the com.example.functional.* pacakge: <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="Functional1"...
Adam Matan's user avatar
  • 134k
7 votes
2 answers
3k views

How to expand folder branch in Project Window Intellij IDEA?

Sometimes I close folder/package in Project Tool Window and then I should click every folder in it to open them . How to avoid this and open all folders/packages quickly?
user2171669's user avatar
5 votes
1 answer
6k views

Why can't I import sun packages?

I downloaded java 9 from https://jdk9.java.net and installed it on my Windows 10 machine. Java 9 has jshell, which I can use to evaluate and learn java programming. Some examples import sun packages, ...
Germano Carella's user avatar
4 votes
1 answer
165 views

Java - Use of nonpublic class from the current package makes compiling error

I've the following two source files File World.java package planets; public class World { public static void main(String[] args) { Mars.land(); } } File Moon.java package planets; ...
Vin's user avatar
  • 753
3 votes
2 answers
6k views

JavaFX vs Java Swing usage in Industry [closed]

Why the developers refused to start new projects using super easy JavaFX package? Why they continue their projects with traditional Java Swing package? What will be the future of JavaFX? Will it be ...
GRTZ's user avatar
  • 330
3 votes
1 answer
5k views

APT: error: attribute 'package' in tag is not a valid Java package name: 'com.mypackage.name_.app'

I have an app which I'm trying to compile with my original package name, very similar to this: com.mypackage.name_.app' The app compiled successfully until now, which I migrated to the newest ...
NullPointerException's user avatar
3 votes
2 answers
3k views

module-info not compiled unless package classes are compiled with the same command

I've got a folder called myModule. Inside it, there's another folder called myPackage in which my Main.class exists. Next to myPackage I have my module-info.java which I'd like to compile. First take ...
Joseph_Marzbani's user avatar
2 votes
1 answer
2k views

Can one Java module export a package whose name is a subpackage of a package from another module? [duplicate]

So I know that, in Java 9 modules (Project Jigsaw), split packages are not allowed. That is, the following modules couldn't both export a package with the same name and also be used at the same time ...
Nick Williams's user avatar
2 votes
1 answer
674 views

SharedPreferences managing between different packages

I'm developing one app, with the package com.example1 and I'm doing another module to use as a library with the package com.example2. On my module (com.example2) I'm using this static functions: ...
Rafael Ruiz Muñoz's user avatar
2 votes
1 answer
249 views

How to organize code logically into package while preserving encapsulation

This is a conceptual question. I usually organize code in packages logically. E.g.: math operation goes in my.package.math or business logic goes into my.package.business and so on. In these days I ...
gixlg's user avatar
  • 1,313
2 votes
1 answer
400 views

Pre-Configured Java Web Application Project

Everytime when I create a new java web project, I have to configure and add many folders and property files for primefaces, hibernate, jsf, ldap, tomcat etc. It wastes all my time. I find a solution ...
Tugrul's user avatar
  • 1,798
2 votes
0 answers
858 views

What's the easiest way to implement the equivalent of Java's package access in Swift?

I have a set of classes in a subfolder (along with a corresponding group in Xcode) that implement the facade pattern: only one class should be used from outside this folder. How do I implement this ...
Kartick Vaddadi's user avatar
2 votes
0 answers
122 views

Using partial package path in Java [duplicate]

I have some classes like a.b.c.v1.Something a.b.c.v2.Something a.b.c.v3.Something There is a place where all of them are visible. Is it possible to arrange that I could refer to them like vX....
Notinlist's user avatar
  • 16.5k
1 vote
3 answers
1k views

Getting java.lang.ClassNotFoundException when using package

I have a java file ComPac.java with the below code: package com; public class ComPac{ public static void main(String[] args) { System.out.println("Hello World"); } } The ...
DockYard's user avatar
  • 1,020
1 vote
2 answers
4k views

How can I import class from the same package in Java?

How can I use one class from other class in the same package in the same directory? I have one class Utils: package pl.jcubic; public class Utils { public static String foo() { return "foo";...
jcubic's user avatar
  • 65.3k
1 vote
2 answers
611 views

Whether we import source code or byte code of a class when importing that class in java?

I have started learning packages in java.I learned about the import keyword.Now my doubt is whether it is .class file or a .java file that is being imported while we import any class in java.
Shashikanth Reddy's user avatar
1 vote
2 answers
7k views

Java Intellj: org.json.simple does not exist

I know that questions have been asked before, but it does not solve my problem in my school project. I downloaded the JSON.simple jar file from https://mkyong.com/java/json-simple-example-read-and-...
Yige Song's user avatar
  • 353
1 vote
1 answer
94 views

How to write package-statements for nested packages?

If I have a class in a sub-package like sub-package-name, which is in a parent-package like higher-level-package-name, do I just write package "sub-package-name"; Or also add the parent-...
Tushar's user avatar
  • 33
1 vote
2 answers
1k views

"Error: Package does not exist" ... Where does the JAR file belong? [duplicate]

I'm trying to import a self made package into a Java project. I got it to work once with some test class. So, when I tried to change it to an official, approved class name, the compiling stopped ...
SpacemanScott's user avatar
1 vote
1 answer
487 views

"null" not allowed in package name

I want to create a java package name where one of the elements is the word "null". Java tells me this is not a valid package: package org.null.thing; public class Foo { public static int ...
IanNorton's user avatar
  • 7,233
1 vote
5 answers
9k views

Run Java Code without a package in Eclipse IDE

I want to run my code without creating a package in java eclipse IDE. But when I do so it is showing error : Must declare a named package because this compilation unit is associated to the named ...
Ramo's user avatar
  • 23
1 vote
2 answers
2k views

same package under different projects

I have a silly question, I have two projects A and B. A is dependent on B. Both A and B have the same package named P. Why classes under project A and Project B in package P can use each other without ...
Jinxin Ni's user avatar
  • 331
1 vote
3 answers
472 views

Import package and how to use all classes in a java file

I am creating a package com.XXXX Inside that I am declaring many classes in a java file (default - not public) let is be like: class A{} class B{} class C{} I am importing com.XXXX in another file I ...
Vivek MVK's user avatar
  • 1,155
1 vote
2 answers
2k views

Is it possible to import several packages at once in Java?

I would like for example to do the following: import packageA.*, packageB.*; but the above notation does not work. Is it possible to do this somehow in Java, or do I always have to type: import ...
Marios Koulakis's user avatar
1 vote
3 answers
1k views

It's possible to run multiple java packages each package has a main class

I have many packages that have classes in an eclipse project under src package each package has a main class each class like this public class A extends TimerTask { public A() { } @Override ...
PHPFan's user avatar
  • 776
1 vote
2 answers
136 views

Java: packaging class files

I have learned Java package. Unfortunately I don't understand why compiling these .java files causes the compile error. I have the following 3 java files: Node.java, InvertedFile.java, and Postings....
inherithandle's user avatar
1 vote
1 answer
4k views

Sudden "package doesn't exist" in IntelliJ IDEA

Recently I started to receive the following errors about random packages: mvn build is working of course, the problem is only for building within Idea. Sometimes I can fix it with reloading maven ...
Dims's user avatar
  • 49.9k
1 vote
0 answers
154 views

pyspark 'JavaPackage' object is not callable

I want to remove the first row of a dataset but this error keeps occuring: 'JavaPackage' object is not callable. I've written another simple program for easier review. Here is my code: # Create a ...
Amirhosein Somi's user avatar
1 vote
1 answer
821 views

Java Error: Could not find or load main class, Caused by: java.lang.NoClassDefFoundError

Compiled I've compiled the java code, but I'm not able to run it. I compiled the code with the following: javac -cp "streamer-client-java.jar:kafka-clients-3.4.0.jar:snappy-java-1.1.10.0.jar:lz4-...
Navaneeth Busha's user avatar
1 vote
0 answers
155 views

How to import a java standard class, from a particular java standard package, from a particular java standard jar?

Short Version How do i do the equivalent of the hypothetical syntax: import plugin.jar.netscape.javascript.JSObject; //import netscape.javascript.JSObject from plugin.jar Long Version I am trying to ...
Ian Boyd's user avatar
  • 253k
1 vote
1 answer
215 views

Is it possible to make scalatest to discover within package object?

I have several test facets sharing multiple test classes, so I aggregate them into a trait to be mixin into package objects, expecting that those test classes will be discovered under the package: (...
tribbloid's user avatar
  • 4,028
1 vote
0 answers
102 views

Access restrictions (modularity) of artifacts in Maven

I know that starting with Java 9 (we're still on 8), it is possible to restrict access to packages for other modules, if you stick to the Java module system. We are doing Java EE and I don't know if ...
J Fabian Meier's user avatar
1 vote
0 answers
140 views

Any way to organize classes within same package

I'm writing a Java library that has a simple interface, but a lot going on behind the scenes. In order to keep the API surface small, I've kept the library as one large package (so that I can make ...
user1902853's user avatar
1 vote
0 answers
485 views

IntelliJ not recognizing classes within the same package - however the program compiles and runs fine

Here's the scene: For some reason, IntelliJ doesn't accept that Util.java or GraphEdge.java are in the MyHelper package. Therefore, method completion doesn't work. This also causes issues in the ...
newbie's user avatar
  • 607
1 vote
0 answers
17k views

HTTP Status 500 - Unable to compile class for JSP

HTTP Status 500 - Unable to compile class for JSP Ok, there are lots of articles about this error and i'm still a newbie. I sow that this error might be caused by some different kind of reasons and ...
Roberto Rizzi's user avatar
0 votes
1 answer
2k views

What do Java subpackages do, given that they don't provide a special access relationship?

I have seen a number of posts on Stack Overflow and elsewhere assert that Java does not have the concept of subpackages. One thing often pointed out is the lack of any special access relationship ...
M. Justin's user avatar
  • 18.6k
0 votes
1 answer
769 views

How to use the package directive?

I am running the following Dog Java code. It can be compiled. However, in order to run it, I had to modify the code to comment out the line (package chap03). It was a code from a textbook. How do I ...
Brian Lee's user avatar
0 votes
1 answer
2k views

Problems with java package names in Gradle build with IntelliJ IDEA

I have a Gradle project and in it I have groovy and java classes at the same package. The build works fine but when I import the project in InteliJ 13 the IDE tells me that only in the java files I ...
Xelian's user avatar
  • 17k
0 votes
2 answers
241 views

Android Studio : Adding a new java file to an existing package - "Unresolved Reference"

I was looking the HTML to PDF Conversion in android app I have a problem to do the "it must be in package ".../java/android/print/" from solution number 1. How can I add the PdfConverter.java in ...
chaviaras michalis's user avatar
0 votes
1 answer
727 views

Run java from command line with non matching folder structure and package name

Java requires no correlation between package names and source code file structure. But most IDE's require sub-folder for each part of the package name. Is the above statement true? To try this ...
tausiq's user avatar
  • 947
0 votes
1 answer
70 views

In Liferay what is the "kernel" package?

I am writing a Liferay hook. When referencing a Java class in Liferay, the "Organize imports" dialog in Eclipse often offers me either com.liferay.portal.TheClass or com.liferay.portal.kernel....
Nicolas Raoul's user avatar
0 votes
2 answers
708 views

Listing abstract classes within a Java package [duplicate]

Is there any way to list all abstract classes within a java package? For example, in java.lang package.
Ricardo Cristian Ramirez's user avatar
0 votes
1 answer
87 views

Error `The declared package "part2.stage2" does not match the expected package ""` with correct package name

So I have a Competitor.java file on path: /home/john/javaStuff/CMTR/src/part2/stage2/Competitor.java. I have VSCode open in the CMTR. So CMTR is my current working directory if that info is necessary. ...
Ecks Dee's user avatar
  • 463
0 votes
1 answer
574 views

How to use javapackager to create executable file for my code? [closed]

I saw this stack overflow post to know how to create executable files from java source , where it says to use javapackager he also says that it is included with Java JDK but I dont have any clue of ...
Pam Ix's user avatar
  • 458
0 votes
3 answers
1k views

How to restrict a class visibility in another class only that are in different packages?

I have the following package and class structure in my project, package de.mycompany.jakarta.order; import de.mycompany.ordermanagement.order.OrderCancellationService; public class DrugOrderManager { ...
Kumar's user avatar
  • 501
0 votes
1 answer
73 views

When or which type of java packages are called native? [closed]

Recently I was improving my understanding on Regular Expressions by reading Mastering Regular Expressions Third Edition by Jeffrey E. F. Friedl, there is mentions Java has had a native regex package . ...
Divya Gupta's user avatar
0 votes
1 answer
64 views

Access class from another package

I have two folders in a folder called asdsad . ├── a │   └── A.java ├── b │   └── B.java This is my A.java package asdsad.a; public class A { public A() { } public int number; } ...
Sparker0i's user avatar
  • 1,821