Create Jar File Programmatically Not Working?

Nov 11, 2014

Why is my create jar file programatically not working? So doing this does create a jar file. When I run the jar file via command line, it gives me "Could not find or load main class ...". I'm not sure exactly why. I took some code i found here: java - How to use JarOutputStream to create a JAR file? - Stack Overflow and apparently it didn't specify the main class so I specifically added it myself. am i doing something wrong? And btw, the file (that contains all the class files) do not have any directories in them. so it's essentially just one folder with a bunch of class files in there. below is the code.

I had the commons-io-2.4 jar referenced into my build path that can be downloaded here: Commons IO - Download Commons IOreason i guess i added to that, though i'm not sure if it was necessary or not, was because it has a file filter which can tell which files are hidden or not and thing is without it it was adding like DS_STORE(which is hidden and i guess unnecessary) to the jar. not sure if this logic is right but just letting you know.

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;

[Code]...

View Replies


ADVERTISEMENT

How To Create PDF File While Working In Java

Feb 22, 2013

how to create pdf file while working in java.

View Replies View Related

Swing/AWT/SWT :: Programmatically Scroll Up Or Down Jtable

Apr 17, 2014

I'm having serious issues right now with a JTable inside a JScrollPane.i have some methods that returns different indexes (rows) that i select programatically in a JTable and the problem is that sometimes it goes beyond of what i can see, like, the row gets selected but the scrollbar won't follow up.

i've searched up in google and saw several different methods but those were extremely complex and for stuff i don't need.the simplest solution i found is this:

tInfo.setRowSelectionInterval(searchIndexes.get(currentIndex), searchIndexes.get(currentIndex));
tInfo.scrollRectToVisible(tInfo.getCellRect(currentIndex, 1, true));

but it just doesn't do anything.My table (tInfo) has only two columns so no horizontal bars, just vertical. What can i do to align the scrollbar with the currently selected row in my table? :C

Found a solution using scrollPane.getVerticalScrollBar().setValue();in another thread, i didn't even notice there were like 3 more threads about the same, just different kind of code used in each.

View Replies View Related

How To Stop Infinite Loop Programmatically

Mar 24, 2015

I am developing application called java compiler... It takes java program as input and compiles and run it, gives output. but if input program has infinite loop then how can identify and stop process execution.

View Replies View Related

Swing/AWT/SWT :: Adjusting JScrollPane Programmatically

Mar 3, 2006

I have a JScrollPane with a JTextArea. The JTextArea is loaded with 10 lines of data. I have two JCheckBox's. The first check box sets the scroll to 10. sp.getVerticalScrollBar().setValue(10); The second check box reloads (ta.setText(text)) the text and then sets the scroll to 10. Why does the second one not work? I have attached a simple program. It is probably easier for you to compile and run than for me to go into detail explaining further.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Tester extends JFrame {
private static final String text = "1

[Code] ......

View Replies View Related

Comparing Data Across Different Database Programmatically?

Oct 22, 2014

I am looking to reconcile data between SQL server and Oracle DB post the migration, I need to verify the data (rows/columns) for last 10 years, Before i start writing a Java Utility to accomplish this, My question is are there any existing libraries or API which can accomplish the same ....

View Replies View Related

JavaFX 2.0 :: Styling Of Controls Doesn't Work programmatically

Dec 9, 2014

I have a stylesheet (mystylesheet.css) with following entry:
 
.flowpane{
    -fx-background-color: rgb(0,0,0);
}
 
In then start-method of my application I execute:
 
       StackPane root = new FlowPane();
        Scene scene = new Scene(root,primaryScreenBounds.getWidth(),primaryScreenBounds.getHeight());
        scene.getStylesheets().add(css.getFile());
        root.applyCss();

No FlowPane gets black. But if I do that in SceneBuilder and add the stylesheet to root than after loading Fxml-file the FlowPane gets black.

Another approach:

        StackPane root = new FlowPane();
        Scene scene = new Scene(root,primaryScreenBounds.getWidth(),primaryScreenBounds.getHeight());
        scene.getStylesheets().add(css.getFile());
        root.getStyleSheets().add(css.getFile());
        root.applyCss();

Nothing happens.

        StackPane root = new FlowPane();
        Scene scene = new Scene(root,primaryScreenBounds.getWidth(),primaryScreenBounds.getHeight());
        scene.getStylesheets().add(css.getFile());
        root.getStyleSheets().add(css.getFile());
        root.getStyleClass().add("flowpanel"); 
        root.applyCss();

Doesn't work too;
 
but root.setStyle("-fx-background-color: rgb(0,0,0) works. But I need to style my application by css-files.

View Replies View Related

Servlets :: Setting Httponly Programmatically In Cookies Doesn't Seem To Work

Nov 5, 2014

I am using servlet 2.4 I used the ff. code below to set httponly in my application's cookies but it did not work. When I do a javascrip alert (document. cooke) in my page, the session id still shows up.

Cookie [] cookies = request.getCookies();
for(int x=0; x<cookies.length; x++){
Cookie cookie = (Cookie) cookies[x];
String cookieValue = cookie.getValue();
cookie.setValue(cookieValue + "; HttpOnly");
}

I also tried doing this and it wouldn't work too

String sessionid = request.getSession().getId();
response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; HttpOnly");

by the way I am using an application server with its JAVA EE version = 1.4 and JAVA SE version = 5

View Replies View Related

Jar File Is Not Working

Feb 25, 2015

I have added a Simple Jar file in Eclipse Proect->BuildPath->jar file but class Inside that are not showing in My project this is my Project Structure and I have all ready checked in Order and Export..But jar file is not working.

View Replies View Related

Reading Text File Into Object Array And Create Random Access File

Dec 9, 2014

I am working on a project that requires me to build a database with random access file, representing products, the base product contains a name (about 30 characters), a price (double), and a quantity (integer). I have worked on this project for probably 15+ hours and have tried so many things and feel like I've barley made any progress...

The part i am really struggling with is taking the data from the text file and creating an object array with it using the product class. Once ive accomplished that, i have to use that data to create a random access file with the data. Here is the base Product class that must be used to create the objects for the array.

public class Product
{
public String pName;
public String stringName;
public double price;
public int quanity;

[Code]...

these continue for about 40-50 entries, they are not seperated by a blank line though i had to add those so it would display correctly, each entry is on its own line with name seperated with spaces, then price after a comma, then quanity after the second comma.....

View Replies View Related

Create New File / Ask User To Write In It And Save Final Print Content Of File

Mar 15, 2014

1. creates a file.
2. ask user to write into that file
3. save the file
4. print content of file.

Is my current exercise, so far i have gotten the code to create a file. What should i use to ask user to write into that file and save?

package assignment7;
 
import java.io.*;
public class Exercise2
{
public static void main ( String [ ] args ) {
String filePath="newfile.txt";
File newFile = new File ( filePath ) ;

[Code] .....

View Replies View Related

Create New File / Ask User To Write In It / Save Finally Print Content Of File

Mar 17, 2014

1. creates a file.

2. ask user to write into that file

3. save the file

4. print content of file.

is my current exercise.so far i have gotten the code to create a file, and ask the user to input their age.what should i use to save what the user writes into the file?

Java Code:

package assignment7;
import java.io.*;
import java.util.*;
public class Exercise2
{
public static void main ( String [ ] args ) throws IOException
{
Scanner scan = new Scanner(System.in);

[code]....

View Replies View Related

Creating A System That Will Ask User To Create A File That Will Store To Text File

Mar 9, 2015

I am new to java and I am creating a system that will ask the user to create a file that will store to a text file, Once the user created the file I have a class that will let the user input the subject name that has been created, However, I keep on getting this java.util.nosuchelementexception.Here's my code:

public void display_by_name()
{
String id, name,total;
String key[]=new String[30];
String value[]=new String[30];
int i=0;

[code]....

View Replies View Related

Read Input File And Create Output With Anagram For Words In File

Sep 24, 2014

Well my code is supposed to ask for an input file and then (ex: input.txt), read the input file and create an output.txt file with the anagram for the words in the file. Also it should be displayed on the screen. However my code doesn't display the anagram on screen or the output file!

Heres is the code:

import java.io.*;
import java.lang.*;
import java.util.*;

/* This program will read a file given by the user, read the words within the file and determine anagrams of the given words. If the file that the user inputs is empty, then the program will output "The input file is empty."
* The program will read the file line by line, counting the total number of words read. If there are more than 50 words, "There are more than 50 words."
* will be printed, and the program will terminate. After each line is read, the words in the line will be separated,punctuation characters will be removed, and upper case characters will be switched to lower case.
* If any word is larger than 12 characters, that word will not be considered in the total amount of words in the file and it will not be sorted.
* After each word is read, the letters will be sorted and stored into an array containing each
* word's 'signature'. After all the words have been read, words will be printed to the output file on the same line based upon their signature.
*/

public class Anagram {
//Creating constants for maximum words in file and maximum chars in word
public static final int MAX_CHARS = 12;
public static final int MAX_WORDS = 50;

[Code] ....

View Replies View Related

JSP :: JQuery Library Is Not Working In File

Dec 17, 2014

I am using Spring to develop a web application.I have used JQuery ui in HTML page it is working fine a Dialog box appear with JQuery effect.But When I use the same procedure in jsp it is not working.Here is my code of jsp file

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
<style>

[code]....

View Replies View Related

JSF :: 2.2 - Not Working Properly With AJAX And File Uploads

Feb 27, 2014

I'm having problems with using the h:inputFile tag with JSF 2.2 and Glassfish 4.0 on Eclipse. The file uploads work when the enctype is set to "multipart/form-data" in the h:form tag, but AJAX will not work. When I leave out the encType (defaults to "application/x-www-form-urlencoded") AJAX works but the uploads do not work, and in fact Glassfish crashes and generates the message:

The request content-type is not a multipart/form-data

Likewise I'm having the same problems with the PrimeFaces file upload tag p:fileUpload. In a JSF 2.0 it works correctly, but with JSF 2.2 it's giving the same problems and generates the message above.

When I start up Eclipse it tells me that Mojarra 2.2.0 is installed. Is this the source of the problem, and if so, how do I install a later version of Mojarra?

View Replies View Related

Reading Input From Text File Not Working?

Apr 7, 2014

public void savePlants(ArrayList flowerPack) throws IOException
{
Scanner input = new Scanner(System.in);
String name;

[Code].....

When I open the saved file the information I need seems to be saved, but when I try to load and search it the data is not there. This is homework that was due about 2 days ago. I just want to get it right in my head for next time.

This is my text file: ¬í sr java.util.ArrayListxÒ™Ça I sizexp w sr FlowerNÏŠ¨r;¾  Z hasScentZ hasThornsL flowerColort Ljava/lang/String;xr Plant"ô²Ò0¢ I IDL Nameq ~ xp t Roset redsr Fungus“ +) Z isPoisonousL fungusColorq ~ xq ~  t toadstool t brownsr Weed #©éÇÙN Z isEdibleZ isMedicinalZ isPoisonousL weedColorq ~ xq ~  t dandylion t yellowsq ~  t tulip t pinkxq ~ q ~ q ~ 

View Replies View Related

Java Database Embedded Exe File Why Not Working

Jul 7, 2014

I have written my whole java code in netbeans IDE and create database in MYSQL work bench and connected java Gui with this DBMS through requried driver.when i run this program from Netbeans IDE , my program successfully access the data from DBMS. But when i created this java gui exe file its not working and not accessing data from DBMS, and each times gives exception "Driver not found ".if there is no driver loaded in this program how this file is working when i run this file from netbeans .

View Replies View Related

Working On A Program That Creates Array From A File

Feb 19, 2015

Working on a program that creates an array from a file, organizes it in various ways, and then prints the results. Right now I'm specifically having trouble with the printAry() method - when I try to run it, I receive a NullPointerException for the active line in printAry() (EDIT: line 102). Not sure which sections are important to this, so I will include the client class and most of the service. I realize that the amount of documentation I included is not necessary, but it is required for the class.

class Lab3StudentAryService
{
private int count;
private Lab3StudentData [] studentAry = new Lab3StudentData[50];

/*
@param: none
@return: none
reads file and converts to array.
*/
public void fillAry() //constructor
{
Scanner scan = new Scanner(System.in);

[code]....

View Replies View Related

How To Create Jar File Of Program With Text File

Jan 29, 2015

i have made one desktop application with swing and i have uses one textfile (File) in it. i want to handover to another friend to use it . How to create jar file of that program with that text file so that my friend use it without any issue . I have made it in NetBeans

View Replies View Related

How To Create GIF File

Feb 2, 2015

is it possible to make a .gif file with jave?

if it is, how is it done?

do i just create a bufferedGif object, or somemthing like that?

View Replies View Related

Can't Create A New File

Jul 17, 2014

code:

import java.io.*;
class FileWrite
{
public static void main(String args[])

[Code]....

error :

d:jpro>javac FileWrite.java
FileWrite.java:11: error: constructor File in class File cannot be applied to given types;
File f=new File(filename);
^

[Code].....

View Replies View Related

Create Jar File

Nov 9, 2014

create a jar file.Currently I have next files in my directory:

Manifest.txt:
-------------
Manifest-Version: 1.0
Created-By: 1.7.0_60-ea (Oracle Corporation)
Main-Class: connectURL

connectURL.class
------------------
it compiled fine, can be executed as:
java connectURL

it does not have 'Package' specified

sqljdbc4.jar
-----------

This is jdbc 4 jar file which is used by connectURL.java to make db. connection.

I am running:
C:j>jar cvfm connectURL.jar Manifest.txt *.class sqljdbc4.jar
added manifest
adding: connectURL.class(in = 2427) (out= 1358)(deflated 44%)
adding: sqljdbc4.jar(in = 584207) (out= 549364)(deflated 5%)

Then trying to execute and get error message

C:j>java -jar connectURL E520 1433
Error: Unable to access jarfile connectURL

View Replies View Related

How To Create A JAR File

Jan 30, 2014

how to create a JAR File I have been watching you tube and it seems like the manifest needs to be remade. I go to the CMD and find my project folder class. I think I need to use do the same for all the classes correct. Well I type jar -cf TictacToeGUIGame.jar *java then I get no such directory. I can see the it worked thought. So do i do this to all my classes and then I will have my JAR program?

View Replies View Related

Can't Create Jar File

Apr 2, 2014

text file:

Codebase: myserver.com
Permissions: sandbox
Application-Name: Dynamic Tree Demo

error message from command line:

C:UsersxxxxDesktopCOMP268applet_ComponentArch_DynamicTreeDemoapplet_Comp
onentArch_DynamicTreeDemouildclasses>jar -cvfm DynamicTreeDemo.jar mymanifest
.txt appletComponentArch
java.io.IOException: invalid header field name: ?≫?Codebase
at java.util.jar.Attributes.read(Attributes.java:433)
at java.util.jar.Manifest.read(Manifest.java:199)
at java.util.jar.Manifest.<init>(Manifest.java:69)
at sun.tools.jar.Main.run(Main.java:172)
at sun.tools.jar.Main.main(Main.java:1177)
[/code]
encoding in UTF-8 and have newline at end

View Replies View Related

Project Is Working On JFrame - But Not Working On JApplet

Apr 10, 2014

I am developing an application to share my client screen with server, it is working well on swing. But i want to develop as web application, i am trying to using applet. But i am facing the fallowing problem..,

1) The Applet screen also open and project also running well on server mechine. But unable to see the client screen on the server.

2) The problem may be to display the JDesktopPane or JInternalFrame.

My working Server Code extends withe JFrame..Java Code:

package remoteserver;
import java.awt.BorderLayout;
import java.awt.Container;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JApplet;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved