How To Add JAR And Config Files To CLASSPATH At Runtime

Jan 23, 2015

During runtime, I need to load the JAR files and relevant config files( .cfg files and .properties file) into CLASSPATH and run a specific java program from one of the JAR which is available in CLASSPATH.

Any relevant Java API details or a sample java program to implement the above use case.

View Replies


ADVERTISEMENT

Runtime Classpath And Compile Time Classpath?

Jan 9, 2014

I compiled a program with a JAR in the classpath. Also ran it with the JAR passed with classpath. For instance I used MySQL .jar.

So I feel it was required in both classpath. I have heard the Servlet API jar is also an example of what is needed at compile time.

View Replies View Related

Compile Java Source Files At Runtime In JRE

Feb 14, 2014

I am looking for a way to compile Java Source-Files at runtime and save them all in an executable jar; almost like an IDE would do. I know that there is the javax.tools package which provides a JavaCompiler interface and you can use ToolProvider.getSystemJavaCompiler() to get an instance of a compiler. However, this method has one important problem: it only works on machines that have the JDK installed. Not when only the JRE is installed.

I guess at this point that I need some kind of third party library that offers an implementation of a JavaCompiler. Unfortunately, this is really complicated to search for on the internet since all top listings when searching "compile java at runtime jre" do not really provide a solution to the problem.

I am writing a (somewhat) complex simulation software right now which is supposed to be used by people who have absolutely no knowledge of programming. At the same time, this software should provide the user with a certain amount of flexibility and control over the flow of the simulation.

My previous take on this problem was to build a complex system to interprete user settings from a GUI. I would basically read the GUI input, output it to some kind of own scripting syntax which I just quickly made up and have that interpreted at runtime. Then I realized, that is a silly concept and I threw it out before I got far into the developement.
The much better solution I came up with is taking the input from the GUI, create java source code from it and compile it at run-time. Seems much cleaner and nicer to me; will also probably have a better performance, but thats not really an issue anyways.

View Replies View Related

Cannot Rename Config File

Mar 3, 2014

When I am trying to rename a config file, ApplicationEdition.txt, I am getting pop up window message "This action can not be completed because the file is open in Java(TM) Platform SE Binary. Close the file and try again." What does this message mean ? How do I close this file, if I don't see it open anywhere ? This file has been used when a cmd was executed, but that cmd has run successfully and its not stuck anywhere then how can this file still be open ?

View Replies View Related

Reading From A Separate Config File

Jul 30, 2014

I am trying to create a bukkit plugin. I need to be able to read from a separate config file but do not know how.

I am trying to use a JSON parser to read from a file but I only need a specific line of the file. Would this work?:

JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader("/plugins/easyRace/config.yml"));
JSONObject jsonObject = (JSONObject) obj;
String Races = jsonObject.get(var "Races:");

View Replies View Related

JRE :: How To Read Deployment Config Properties

Mar 4, 2015

How do I get java to tell me what it thinks the current deployment configuration properties are? I'm aware of Deployment Configuration File and Properties and see it tells me what the values are,  how to set them, etc.  But what I want is a way to run java and have it cough up what it's currently using.  Something like 'java -display-config-properties' and have it spit out all current values it's using.

View Replies View Related

Get Data From Config File And Store In Array Without Using Split Method

May 8, 2014

How i can get the data from a file, for a key that have multiple values without using split method and i want to store that data in an array

file name:"new.txt"[contains below data]
Name=google.com, yahoo.com,facebook.com
Attachment=abc1,abc2,abc3

I am successfully able to do this using following code

Properties props = new Properties();
String configFilePath = (Cjava_confignew.txt);
props.load(new FileReader(configFilePath));
String TestName = props.getProperty(Name);
String test[] = TestName.split(,);

Now i just want to store the values for key "Name" in array without using TestName.split(,); but i am not able to do this.

I have also used .yml file to avoid this but did not succeed, some way to do this

file name test.yml

Name
-google.com
-yahoo.com
-facebook.com

Attachment
-abc1
-abc2
-abc3

i want to store multiple values for single key(Name) within the array

View Replies View Related

JSP :: How Is Classpath Set For JSTL

Sep 9, 2014

I am looking at JSP page, which has code line as follows

<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

This taglib will have to be installed on local environment. How is it referred in jsp ? I dont see any code in jsp, which refers to the location of JSTL. So how does jsp invoke these tags ? Is it through classpath ?If its so , how is classpath set for JSTL ? Is it just as classpath is set for java ?

View Replies View Related

Include EAR File In Classpath?

Jan 23, 2014

I am writing an Ant script using the javac command but the library I need is bundled in an ear file, how can I reference this jar in ear file without extracting the ear file.

View Replies View Related

EJB / EE :: Java Classpath Error

Jun 11, 2014

I'm trying to run an enterprise java application running glasssfish server from my university ( the open university, distance learning and i recommend it). I get the following error:

pre-init:
init-private:
init-userdir:
init-user:
init-project:
do-init:
post-init:
init-check:
init:

[code]...

The Java EE server classpath is not correctly set up - server home directory is missing.Either open the project in the IDE and assign the server or setup the server classpath manually.For example like this: ant -Dj2ee.server.home=<app_server_installation_directory> BUILD FAILED (total time: 0 seconds)

View Replies View Related

Classpath With Ant Deployment Not Working

Sep 6, 2013

I am having an issue that I cannot seem to resolve with Ant deployments and my Classpath.
 
I have a module that is needed to run with Open Wonderland but for some reason when I run this particular module deployment it doesn't recognize part of the classpath.
 
On my server I have a class called JadeRunner.class and it is included in my classpath.  I can verify but running the following code:

public class testClassPath{
     public static void main(String args[]){
          String classArg = args[0];
          try{
             Class testClass = Class.forName(classArg);
          }catch(ClassNotFoundException e){
             e.printStackTrace();
          }
     }
}

I just enter the name of the class as an argument and if I get no errors that it can find the class.  This works if I enter it directly from the command line.  However with my ant deployment I get a ClassNotFoundException for this class.
I run my ant deployment as root but I use the -E switch so it picks up my environment variables.  The ant deployment finds all my other environment variables except this one. 

I have some sample outputs:

$ java testClassPath org.jdesktop.wonderland.modules.mas.jade.weblib.JadeRunner  (this give no output, so it finds the class)
$ sudo -E java testClassPath org.jdesktop.wonderland.modules.mas.jade.weblib.JadeRunner  (again no output, so it finds the class)
$ sudo -E ant deploy

This gives ClassNotFoundException: org.jdesktop.wonderland.modules.mas.jade.weblib.JadeRunner

View Replies View Related

JVM - Classpath From A File Or MainClass From Outside Jar?

Sep 19, 2014

I need to start a new JVM. To do this my (production-) code pick a certain jar and starts a class in it. The name of this class is not fix. The picked jar has other jars in its Manifest class path section.
 
For my tests I want to replace my jars red from the main jar with the compile target folders of my Eclipse projects that make up my Application.
 
Getting that folders is quite easy because i configured the Starter project to depend on the other Projects of my app so that they are available via System.getProperty("java.class.path"). But eclipse creates absolute path in there. The result is that I cannot use the output of System.getProperty("java.class.path") as command line parameter, it's simply to long.
 
I tried to put the class path in a temporary jar file but it looks like that the jars class path is not added to the resulting class path when i is simply added as another classpath entry at command line. On the other hand I cannot run this temporary jar file via -jar option because the main class cannot be found if it is not located in the temporary jar...
 
Meanwhile I found that the main problem is not so much the other Projects but the 3rd party libs which eclipse refers them in their maven repository location. They blow up my classpath. I tried to convert their paths to relative but this didn't change that much...
 
So my question is:
1. is there a way to provide the classpath in a text file to java executable on command line?
2. is there a way to run a jar with the -jar option if the main class is outside the jar (but within the classpath in the jars manifest)?
3. is there any other way to solve my problem resulting from the limited command line length?

View Replies View Related

EJB / EE :: Classpath Requirements For Facelets And CDI On Glassfish

Oct 29, 2014

I don't understand the classpath requirements for facelets and CDI on glassfish. I'm using Netbeans, and have the following:

thufir@dur:~/NetBeansProjects/EntAppWeb$ jar -tf dist/EntAppWeb.ear
META-INF/
META-INF/MANIFEST.MF
lib/
EntAppWeb-ejb.jar
EntAppWeb-war.war
lib/javaee-api-7.0.jar
thufir@dur:~/NetBeansProjects/EntAppWeb$

when I look at javaee-api it has javax.enterprise.context.ApplicationScoped and javax.inject.Named which are the particular imports being used in the bean. The facelets part is working, the template navigates correctly. It deploys to Glassfish and runs, except...there's no output from the @Named bean:

package dur.beans;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
@Named("nextClient")
@ApplicationScoped
public class NextClient implements NextClientLocal {

[code]...

Now it's working. I can't figure what I did for the life of me...that's the desired output, each time the page is accessed the counter increments.Now it works. Is this on the right track? Way off base? I have an entity class from a database which I'd like to link up to this, and output the class.I can inject the entity into NextClient? I'm trying to do the "R" for Read in a CRUD application with CDI and facelets (using templates).

I've found much reference material on EJB, but it seems a mishmash. I just want to use CDI. What am I doing right/wrong, or, besides the PDF from Oracle on Java EE 7, what are good CDI reference material's?

View Replies View Related

Trying To Add Database Driver (JDBC) - Not In CLASSPATH Warning?

Jun 23, 2015

This the output of java from my PC under linux platform (rhel 6.5).
 
[pentaho@vertica-srv1 Downloads]$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
 
[Code] ....
 
But the problem is while trying to open ETL program under linux platform [pentaho@vertica-srv1 data-integration]$ ./spoon.sh .... I received the following error messages.
 
[pentaho@vertica-srv1 data-integration]$ ./spoon.sh
 
Trying to add database driver (JDBC): RmiJdbc.RJDriver - Warning, not in CLASSPATH?
Trying to add database driver (JDBC): jdbc.idbDriver - Warning, not in CLASSPATH?
Trying to add database driver (JDBC): org.gjt.mm.mysql.Driver - Warning, not in CLASSPATH?
Trying to add database driver (JDBC): com.mckoi.JDBCDriver - Warning, not in CLASSPATH?
[KnowledgeFlow] Loading properties and plugins...

View Replies View Related

Entering CLASSPATH In Manifest File When Directory Is Not In Root?

Jul 1, 2014

I'm trying to add a CLASSPATH to a manifest file linking (not sure If that's the right word) to an sqljdbc4.jar file.

If I copy the file Into my root folder and use CLASSPATH: sqljdbc4.jar It works fine.

Class-Path: sqljdbc4.jar
Main-Class: com.ncntech.go

If I try CLASSPATH: C:Program FilesMicrosoft JDBC Driver 4.0 for SQL Serversqljdbc_4.0enusqljdbc4.jar I receive a "Could not find or load main class" error.

Class-Path: C:Program FilesMicrosoft JDBC Driver 4.0 for SQL Serversqljdbc_4.0enusqljdbc4.jar
Main-Class: com.ncntech.go

Is the syntax correct for specifying a directory path ?

View Replies View Related

JavaFX 2.0 :: SceneBuilder - Preview Classpath-relative Images

May 7, 2014

When I assign a classpath-relative URL to an ImageView's 'Image' property, SceneBuilder is unable to display the Image in the Preview. It shows the text "Image not found" instead as a placeholder, which makes sense. What I'd like to do is add a classpath entry to SceneBuilder such that it is able to locate and display the Images. Any way to accomplish this (or similar)?

View Replies View Related

How To Create Java Files Into Windows Applications (Exe Files)

Oct 26, 2014

What step to know to develop software..

View Replies View Related

How To Attach External Files To Executable Jar Or Exe Files

Apr 13, 2015

In a program I created, I'm using a text file that contains some texts needed for the program. The method relevant to this is something like the following.

private String wordgen(){
try {
BufferedReader reader = new BufferedReader(new FileReader("src/Resources/adjectives.txt"));
Random rand = new Random();
int low = rand.nextInt(400);
String fil="";
int i=0;
while(i!=low){

[Code]...

The program runs fine in netbeans project but once the jar is created it does not corporate with the text file. ("null" is returned) How can I attach text files to jar and exe?

View Replies View Related

Getting RunTime Exception ClassCastException

Feb 28, 2014

i am getting runtime Exception Saying classCastException .here is my code where i am getting classcastException.

public class ModifyDetailsServlet extends HttpServlet {
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

[code]....

View Replies View Related

Runtime Error On View Contacts

Feb 9, 2015

why get a runtime error when choosing option 2 after adding a contact?

Main:

package contactlist;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

[code]....

View Replies View Related

Can't Change GridWorld Grid During Runtime

Jun 5, 2014

I have a question about updating a grid during runtime in GridWorld. I'm making a game called Flood-It (basically, you click on squares to change their color and attempt to get all of the squares the same color in the grid) and I'm having trouble with changing the grid size. I made my own world class, called CellWorld.

import info.gridworld.actor.*;
import java.util.ArrayList;
import info.gridworld.grid.Location;
import java.awt.Color;
import javax.swing.JOptionPane;

[code]...

Now, let me narrow down the issue. It is in the runner class:

world.setGrid(new BoundedGrid<Actor>(world.getLength(),world.getWidth()));

Whenever a user wants to change the grid size after playing the game, this is supposed to set the grid to the new updated size, but it never changes in the actual game, i.e. the user just won a 2x2 game, attempts to change the size to 10x10, but the grid stays 2x2. By debug testing, I can say for certain that everything else works, such as the maxStepCalc and loading the grid. The only issue is the new grid not showing up.

View Replies View Related

How To Add Computed Column To TableModel At Runtime

Apr 3, 2014

How can I add computed/derived column to an existing TableModel ?

I've 7 column in the existing TableModel. Now I've to add 8th column and it'll be based on Col2, Col3 & Col5.

Value of Col8 should be in following logic.

public TableModel GetDerivedTable(ResultSet rs){
TableModel model = GetTable(rs); // I've done this

//Now have to modify here

If(Col2==true && Col5==true)
Then{Col8 = 1}

[Code] ....

View Replies View Related

How To Change Location Of JTextArea At Runtime

Feb 11, 2014

I am using Swing, I have a JPanel and in it there is a JTextArea and a JButton. I want the JTextArea to move when the button is clicked on. I'm Not really sure how to do the action listener for the button. at the moment the JTextArea only moves once when the button is clicked on, but i want it to move every time the button is clicked on.

This is what i have so far:

moveButton = new JButton("MOVE");
moveButton.setName("move");
moveButton.setBounds(20, 140, 70, 40);
text = new JTextArea("hello");
text.setEditable(false);
text.setBounds(x, 50, 40, 20);
panel.add(moveButton);
panel.add(text);

In the actionPerformed method this is what it does:

text.setBounds(x + 50, 50, 40, 20);
panel.add(text);
text.setVisible(true);

View Replies View Related

How To Take Runtime Value For Static Final Variable

Jul 28, 2014

How can i take run time value for static final variable...my lecturer said first time assignment is possible for declared final variable but in my case it shows compile time error..I'm placing my program below with error message

class Sample
{
static final String cname;
void print() {
System.out.println(cname);
}
public static void main(String args[])
{
cname=args[0];
Sample s=new Sample();
s.print();
}
}

Sample.java:11: cannot assign a value to final variable cname.
cname=args[0];

View Replies View Related

How To Add Computed Column To ResultSet At Runtime

Apr 7, 2014

I'm working in a project where a particular part has been assigned to me. I've a ResultSet of informations like below:

EmpId EmpFirstName EmpLastName EmpAge 1 ABC DEF 43 2 PQR XYZ 37

Now I've to send this ResultSet(to another function) with EmpFullName in following manner.

EmpId EmpFirstName EmpLastName EmpFullName EmpAge 1 ABC DEF DEF, ABC 43 2 PQR XYZ XYZ, PQR 37

There is no permission for me that I can change SQL query(or anything like this), and I've to return the modified ResultSet(not TableModel). I googled a lot to implement AbstractResultSet, but no luck for me. How can I achieve this ?

View Replies View Related

Runtime Error In Package Program

Jan 20, 2015

Iam getting this error at run time while using this command "java mypack.Accountbalance". I have compiled this source code and got its class file that I have put in mypack package but now its showing this error ..

Here's the code :
package mypack;
class Balance
{
String name;
double bal;
Balance(String n ,double b)

[Code] .....

Error:
exception in thread "main" java.lang.NoClassDefFoundError: mypack/Ba
at mypack.Accountbalance.main(Accountbalance.java:25)
used by: java.lang.ClassNotFoundException: mypack.Balance

View Replies View Related







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