Transferring a WHOLE netbeans GUI project - java

Alright, so for a homework assignment I had to make a simple application with java swing. I used the netbeans GUI builder to do it and it works fine. However, when I zip up the entire folder (Documents\NetBeansProjects\Lesson 7) my professor complains that he doesn't have all the files. What other files could there be? I'm zipping up the whole folder that includes build, nbproject, src, test, build.xml, and manifest.mf. Is there anything else I need to zip up, or is my professor doing something wrong?

Netbeans GUI Designer uses the:
Swing Application Framework (JSR-296)
Netbeans keeps those separate as libraries (see the Libraries Item in the Projects view of Netbeans). Netbeans Libraries can be viewed under:
Tools --> Libraries
In order to run your application, you will need to supply the 'appframework' and 'swing-worker' jar files so that they can be added to the classpath in order to run the application.

Related

Full java code from Netbeans Project

How can I get the full java code of a netbeans project? I have created a project for a contest, but need to submit the whole code. In Netbeans alot of the libraries and classes code is hidden. I need to submit all this. Even if a plugin needs to be installed.
Thank You :)
Assuming you have a NetBeans Project named HelloWorld in your system,let's assume that the default directory of storage of NetBeans Projects is in
C:\Users\USERNAME\Documents\NetBeansProjects\HelloWorld // On Windows OS
/home/NetBeansProjects/HelloWorld // On *nix(Linux,Unix) based OS
If it is different from the above,then please switch to the default directory of the Netbeans Projects.
Select your project folder from that,HelloWorld here.
It'll have several directories(folders) inside.
Switch over to src folder. All the .java files are placed in that directory. Those are the source code in Java. You can open and check and verify those files using any text-editor like Notepad,Gedit,etc.
NOTE :- DON'T DELETE ANY OTHER FOLDER/FILES unnecessarily,else,your NetBeans project won't be recognised/won't run properly.

NetBeans Project - make project code unreadable

I have a java project that I created in the NetBeans IDE version 8.0.1. The project contains a gui which I created with the NetBeans Gui builder, two external API's, and of course some of my personal code. I would like to make this project available to the public, but I don't want someone to be able to just take my project and upload it into an IDE and see all of my work. How do I need to go about making my project codew private and/or inaccessible. All the user should be able to do is run the jar file and use all the functionality of the program. Thanks for the help!
By default JAR files are build without sources if you use NetBeans (with its Ant-based build system), Maven or Gradle. It will only contain *.class files and resources (text, XML, images and other files).
Of course it is possible to decompile *.class files from your JAR. If you want to go an extra step you can obfuscate generate code to make it harder to understand what's going on there.

Jar file too big

I created a simple project using WindowBuilder in Eclipse and my goal is to send it by email. I don't know what kind of computer the person is using, so I exported my project into a 'Runnable JAR File' and checked the option 'Extract required libraries into generated JAR'.
The problem is that the generated JAR file is 20MB in size!!! The project has only one simple window - nothing complicated or fancy.
I found that some people use ProGuard to include only what is really needed.
I would like to know if there is a way to optimize it 'manually'? Are there libraries that are automatically included when creating a WindowBuilder project, and how may I determine which libraries I can remove?
Thank you.
I've had the same Problem using WindowBuilder. My solution was to look for the imports in my .java file, e.g.: import org.eclipse.swt.SWT;
In the Project Explorer in Eclipse you can see that there are much more imports than needed. Those 'Build Paths' can be removed carefully.
Simply rightclick on a .jar import like "com.ibm.icu_52.1.0.v201404241930.jar" and click on "Build Path" and "Remove from Build Path". Unfortunately, you can't remove or delete the packages inside the .jars.
But using this method, I managed to reduce the size from 20.7MB to 3.87MB. It's something...
Like fge said, send the source. Or upload the .jar to dropbox if you require you partner to access all of the files in the .jar.
If you don't like dropbox, find some other cloud storage solutions through a google search. Github or Bitbucket could also be an alternative to dropbox.
Cheers.
Use the Eclipse plugin FatJar. FatJar shows you which libraries are getting imported and allows you to specify which .jars, libraries, etc., that you want built into your JAR.
FatJar
Your jarfile is too big due of the project template. Create a sample java project, then use windowdbuilder components. Do not create a project Swing Template, by this way eclipse is gonna import all eclipse gui toolkits.
Tried it out with my way, my application's length equals to 3Ko against 24MO with the template project

Exporting a SWT Project in Eclipse (Project Setup via SWT Designer)

I made a small application with java in Eclipse using SWT for my GUI. I set up the project by installing SWT Designer, which is very similar to Swing Designer only for SWT. I created the project by going to File >> New >> Other >> Window Builder >> SWT Designer >> SWT/JFace Java Project. This set up the whole project for me so I could start using SWT. My program successfully runs when I use Eclipse to run it.
I want to be able to run it without Eclipse, though. I tried to export it as a .jar by going File >> Export >> Java >> JAR file. I selected my project, hit Next >> Next, then I set my main class and hit finish. No errors.
Opening the .jar gave me:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Layout
It was pretty clear that SWT isn't where it should be, so I opened the .jar and found only my files, the META-INF, etc. No SWT anything. No jar, no org folder, nada.
In my Eclipse project, under the Project Explorer, it lists "Referenced Libraries", where the SWT stuff is set up. When looking under the properties of it, it lists a bunch of org.eclipse... stuff. I assume this is how Eclipse knows what to run, but it seems to not export it.
So my question is: How do I get the project to export with SWT packaged with it, in order to be able to run by the .jar alone? It would be nice if you could explain both the manual way (i.e. editing the META-INF and dragging and dropping the required SWT files) and also explain the Eclipse export way (so I don't have to do the manual way all the time), if there is a way to do it in Eclipse.
EDIT: If you see my answer below, I explained how I was able to get this working, however, it dumps ~16MB worth of code into my .jar, which is pretty big for an originally < 1MB project. If you have any idea on how to make it only add the used files, an answer is still appreciated. ;)
Does not sounds like you are using OSGI, my suggestion would be to go to your eclipse plugin directory, grab the swt jar copy it into your plugin and add it to the classpath by going to manifest editor, runtime tab and selecting the jar. If you are running an osgi app, make sure your .product file has the correct dependencies by going to .product editor dependencies tab and selected add required plugins. If you are running this in a different context comment and I will answer.
The way I successfully made this work, was by exporting it as a runnable JAR.
My steps to getting it working:
Run the main class. (I specifically use CTRL+F11, the default run on the class, letting Eclipse guess how it's supposed to be ran.)
Go to File >> Export >> Runnable JAR.
Select my Launch Configuration. (It's listed when I hit the arrow beside the run button on the top bar on Juno.)
Hit the finish key and wait!

Eclipse Plug-in development. Can i use an already existing jar file with my plug in?

Im writing a server based application and i would like eclipse to be able to interact with it.
I was wondering if eclipse PDE can handle using an external jar to interact with RabbitMQ. Also would i have access to the editor i.e. could the server respond and then update the code on the users end inside the editor pane?
Also if anyone knows any good resources for eclipse plug-in development that would be great as the only books i can find on amazon are a few years old
Thanks,
Ben
You can include any JAR in your plugin and write code that uses it.
Copy the JAR into your plugin project (usually they're placed into a lib folder in the project).
Open your plugin's manifest or plugin.xml file and go to the Runtime tab.
In the Classpath section, use the Add... button to add the JAR.
Go to the Build tab and make sure the JAR is selected at least for the Binary Build.
Save.
Now you should be able to write code that uses the JAR and when you build your plugin it will be packaged in your plugin.
If you find that you'll be writing multiple plugins that go together and all use the same JAR(s), there's a better way to package it, but I'll leave those details out for now.

Categories

Resources