where are the "external" JAR's? - netbeans

Where is the lib folder with the JAR's? Is there some magic to load the JAR's from another directory?
Specifically, where is beansbinding-1.2.1.jar and the other jar is swing-layout-1.0.4.jar?
image
directory structure:
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$ tree fud/
fud/
├── build.xml
├── manifest.mf
├── nbproject
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── private
│   │   ├── private.properties
│   │   └── private.xml
│   ├── project.properties
│   └── project.xml
└── src
└── dur
└── bounceme
└── net
└── view
├── NewJFrame.form
└── NewJFrame.java
7 directories, 10 files
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$ head fud/build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="fud" default="default" basedir=".">
thufir#dur:~/NetBeansProjects$

you have an option of add Jar/Folder just below Add Library . Use that

Just for reference, I got the following structure:
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$ tree fud/
fud/
├── build.xml
├── lib
│   ├── beans-binding
│   │   ├── beansbinding-1.2.1-doc.zip
│   │   └── beansbinding-1.2.1.jar
│   ├── CopyLibs
│   │   └── org-netbeans-modules-java-j2seproject-copylibstask.jar
│   ├── nblibraries.properties
│   └── swing-layout
│   ├── swing-layout-1.0.4-doc.zip
│   ├── swing-layout-1.0.4.jar
│   └── swing-layout-1.0.4-src.zip
├── manifest.mf
├── nbproject
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── private
│   │   ├── config.properties
│   │   ├── private.properties
│   │   └── private.xml
│   ├── project.properties
│   └── project.xml
└── src
└── dur
└── bounceme
└── net
└── view
├── NewJFrame.form
└── NewJFrame.java
11 directories, 18 files
thufir#dur:~/NetBeansProjects$
by clicking on the project properties as so:
but don't understand where this JAR's were before.

Related

How to access javax/persistence/ from client?

When running java hwai.Main from directory target/classes, I get an error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Persistence
at hwai.Main.main(Main.java:17)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Persistence
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
...
I get the same error when I'm running java hwai.Main from directory target/test1/WEB-INF/classes
This is my project structure after running mvn package glassfish:redeploy:
├── pom.xml
├── src
│   └── main
│   ├── java
│   │   ├── hwai
│   │   │   ├── helloWorld.java
│   │   │   ├── helloWorldResource.java
│   │   │   ├── Main.java
│   │   │   ├── StudentPOJO.java
│   │   │   ├── StudentRest.java
│   │   │   └── Todo.java
│   │   └── META-INF
│   │   └── persistence.xml
│   └── webapp
│   ├── index.html
│   └── WEB-INF
│   └── web.xml
└── target
├── classes
│   └── hwai
│   ├── helloWorld.class
│   ├── helloWorldResource.class
│   ├── Main.class
│   ├── StudentPOJO.class
│   ├── StudentRest.class
│   └── Todo.class
├── generated-sources
│   └── annotations
├── maven-archiver
│   └── pom.properties
├── maven-status
│   └── maven-compiler-plugin
│   └── compile
│   └── default-compile
│   ├── createdFiles.lst
│   └── inputFiles.lst
├── test1
│   ├── index.html
│   ├── META-INF
│   └── WEB-INF
│   ├── classes
│   │   └── hwai
│   │   ├── helloWorld.class
│   │   ├── helloWorldResource.class
│   │   ├── Main.class
│   │   ├── StudentPOJO.class
│   │   ├── StudentRest.class
│   │   └── Todo.class
│   ├── lib
│   │   ├── commonj.sdo-2.1.1.jar
│   │   ├── eclipselink-2.7.0.jar
│   │   ├── javax.json-1.0.4.jar
│   │   ├── javax.persistence-2.0.0.jar
│   │   └── validation-api-1.1.0.Final.jar
│   └── web.xml
└── test1.war
Searching the internet, I found Eclipse Warnings: class javax.persistence.* not found and java.lang.NoClassDefFoundError: javax/persistence/Persistence, but neither helped me. I'm quite a javaee newbie.
pom.xml contains among others
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
The import - statement in Main.java is
import javax.persistence.Persistence;

Where does groovy look for properties files by default?

For this Netbeans project:
.
├── build.xml
├── manifest.mf
├── nbproject
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── groovy-build.xml
│   ├── private
│   │   └── private.properties
│   ├── project.properties
│   └── project.xml
└── src
├── Config1.groovy
└── net
└── bounceme
└── mordor
└── groovy
└── file_ops
└── NewGroovyScript.groovy
8 directories, 10 files
what would the standard location, or path, for foo.properties so that it can be easily picked up? in src?
You should be able to stick it in the same folder as your NewGroovyScript.groovy class file, then just do:
Properties p = NewGroovyScript.class.getResource('foo.properties').withInputStream { s ->
Properties properties = new Properties()
properties.load(s)
properties
}

Game_ cannot be resolved to a variable in arquillian persistance example

I was asking on #arquillian Freenode IRC channel about question
Arquillian JPA tutorial: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
when a user told me that he successfully runned
https://github.com/arquillian/arquillian-examples/tree/master/arquillian-persistence-tutorial
so I did
git clone https://github.com/arquillian/arquillian-examples.git
then in Eclipse, I clicked File->Import->Existing Maven Projects and selecte the subdirectory
arquillian-examples/arquillian-persistence-tutorial
Once Eclipse finished importing the project, I obtain in file
/src/test/java/org/arquillian/example/GamePersistenceTest.java
line 146, the error message
Game_ cannot be resolved to a variable
What can I do? In my attempt at the link at beginning of the page, this did not happpen.
I did not change any file downloaded from git repo.
Folder tree
.
├── pom.xml
├── src
│   ├── main
│   │   ├── java
│   │   │   └── org
│   │   │   └── arquillian
│   │   │   └── example
│   │   │   └── Game.java
│   │   └── resources
│   │   └── META-INF
│   │   └── persistence.xml
│   └── test
│   ├── java
│   │   └── org
│   │   └── arquillian
│   │   └── example
│   │   └── GamePersistenceTest.java
│   ├── resources
│   │   ├── arquillian.launch
│   │   ├── arquillian.xml
│   │   └── jbossas-ds.xml
│   ├── resources-glassfish-embedded
│   │   ├── glassfish-resources.xml
│   │   ├── logging.properties
│   │   └── test-persistence.xml
│   ├── resources-glassfish-remote
│   │   └── test-persistence.xml
│   └── resources-jbossas-managed
│   └── test-persistence.xml
└── target
├── classes
│   ├── META-INF
│   │   ├── MANIFEST.MF
│   │   ├── maven
│   │   │   └── org.arquillian.example
│   │   │   └── arquillian-persistence-tutorial
│   │   │   ├── pom.properties
│   │   │   └── pom.xml
│   │   └── persistence.xml
│   └── org
│   └── arquillian
│   └── example
│   └── Game.class
└── test-classes
├── arquillian.launch
├── arquillian.xml
├── glassfish-resources.xml
├── jbossas-ds.xml
├── logging.properties
├── org
│   └── arquillian
│   └── example
│   └── GamePersistenceTest.class
└── test-persistence.xml
30 directories, 24 files
The _Game class in that example is generated by the Hibernate JPA 2 metamodel generator (hibernate-jpamodelgen) that is defined as a dependency in the project POM. You'll now need to generate the metamodel by employing one the options outlined in the metamodel generator reference guide.
You could use Eclipse itself by configuring the annotation processing phase. Or you could modify the POM to use the maven-compiler-plugin configuration specified in the guide, to run as part of your build.

What goes where in Spring MVC Maven Eclipse Juno STS 3.0.0 project?

I'm creating a new Spring MVC webapp.
I used STS 3.0 Dashboard -> Spring Template Project -> Spring MVC Project (URL:http://dist.springsource.com/release/STS/help/org.springframework.templates.mvc-3.1.2.zip) to create the project. It created a directory structure like this:
build/
classes/
src/
main/
java/
com/
example/
web/
HomeController.java
resources/
META-INF/
log4j.xml
webapp/
resources/
WEB-INF/
classes/
spring/
appServlet/
servlet-context.xml
root-context.xml
views/
home.jsp
web.xml
test/ ***(I'll leave out what's under test)***
target/
classes/ ***(I'll leave out what's under classes)***
test-classes/ ***(I'll leave out what's under testclasses)***
WebContent/
META-INF/
MANIFEST.MF
WEB-INF/
lib/
This does not match any directory layout I can find documentation for and it certainly looks wrong. Like why is there a WebContent/WEB-INF as well as a src/webapp/WEB-INF? Why both a build/ and a target/ ?
I want to be able to build and deploy automatically from Eclipse Juno as well as from the command line using Maven, so question 1 is: how do I clean up this directory structure?
Question 2: what is the difference between src/main/resources/ and src/main/webapp/resources? How do I choose which directory to put a given static resource in?
Question 3: If I have libraries that I need to include that I cannot have Maven get, where do I put them?
I tied it in my local and following is the folder structure:
.
├── pom.xml
├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │   └── test
│   │   │   └── spring
│   │   │   └── HomeController.java
│   │   ├── resources
│   │   │   ├── log4j.xml
│   │   │   └── META-INF
│   │   └── webapp
│   │   ├── resources
│   │   └── WEB-INF
│   │   ├── classes
│   │   ├── spring
│   │   │   ├── appServlet
│   │   │   │   └── servlet-context.xml
│   │   │   └── root-context.xml
│   │   ├── views
│   │   │   └── home.jsp
│   │   └── web.xml
│   └── test
│   ├── java
│   │   └── com
│   │   └── test
│   │   └── spring
│   └── resources
│   └── log4j.xml
└── target
├── classes
│   ├── com
│   │   └── test
│   │   └── spring
│   │   └── HomeController.class
│   └── log4j.xml
├── m2e-wtp
│   └── web-resources
│   └── META-INF
│   ├── MANIFEST.MF
│   └── maven
│   └── com.exigen
│   └── spring
│   ├── pom.properties
│   └── pom.xml
└── test-classes
├── com
│   └── test
│   └── spring
└── log4j.xml
(I removed the .XXX files/folder which just the metadata for eclipse)
Basically, for you question:
Typical src/webapp/WEB-INF is the maven way and WebContent/WEB-INF is the WTP way. And the maven way is suggested.
Also build/ is generate by eclipse and target/ is the maven way, you can just ignore this.
for Question2, src/mian/resources is the maven way which will be compiled to the target/classes folder. and 'src/main/webapp/resources' is used for some static resources.
for Question3, actually all the 3rd-party libraries are house in the WEB-INF/lib after package, so you can put your libraries into this folder, no matter using maven or not.

Which folders are unnecessary while deploying a play! app?

I have finally made a production worthy app with play, and use the play war -o foo command to create an exploded war. However, its size goes on to 30 MB and there are a lot of folders included. I develop in eclipse, so there are some eclipse folders too. Below is a list of the folders I have. Can anyone help me out with the unnecessary folders? I have zeroed in on the app, conf, public and lib folders. Is my assumption correct?
├── app
│   ├── controllers
│   ├── jobs
│   │   ├── daily
│   │   └── monthly
│   ├── models
│   │   ├── encrypt
│   │   ├── file
│   │   ├── login
│   │   └── mail
│   ├── playground
│   └── views
│   ├── Application
│   └── errors
├── conf
├── eclipse
│   └── classes
│   ├── controllers
│   ├── jobs
│   │   ├── daily
│   │   └── monthly
│   ├── models
│   │   ├── encrypt
│   │   ├── file
│   │   ├── login
│   │   └── mail
│   └── playground
├── lib
├── logs
├── public
│   ├── bootstrap
│   │   ├── css
│   │   ├── img
│   │   ├── js
│   │   │   └── tests
│   │   │   ├── unit
│   │   │   └── vendor
│   │   └── less
│   ├── images
│   ├── javascripts
│   └── stylesheets
├── test
└── tmp
├── bytecode
│   └── DEV
└── classes
├── controllers
├── helpers
├── jobs
│   ├── daily
│   └── monthly
├── models
│   ├── encrypt
│   ├── file
│   ├── login
│   └── mail
└── playground
You need to delete your tmp folder as well, try to use play clean on your project.
All folders in app, conf, lib and public should be kept in your war. Maybe should add precompiled